@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@500;700;800&display=swap");

:root {
  --bg: #fff5f8;
  --bg-2: #fff9e8;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --line: rgba(255, 60, 120, 0.16);
  --text: #1a1020;
  --muted: #6b4a5a;
  --accent: #ff2d6a;
  --accent-2: #ff6b2c;
  --cyan: #19d4e6;
  --sun: #ffd23a;
  --mine: #ff2d6a;
  --peer: #ffffff;
  --danger: #e11d48;
  --ok: #12b981;
  --radius: 18px;
  --font-display: "Fredoka", "Nunito", sans-serif;
  --font-body: "Nunito", "Fredoka", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 500 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 55% at 10% 0%, #ff8ab8 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 15%, #7aecff 0%, transparent 50%),
    radial-gradient(ellipse 90% 60% at 50% 100%, #ffe566 0%, transparent 55%),
    linear-gradient(165deg, #fff5f8 0%, #fff9e8 45%, #e8fbff 100%);
  animation: skyShift 14s ease-in-out infinite alternate;
}

body::after {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 45, 106, 0.22) 0 12%, transparent 13%),
    radial-gradient(circle at 78% 22%, rgba(25, 212, 230, 0.2) 0 10%, transparent 11%),
    radial-gradient(circle at 60% 75%, rgba(255, 210, 58, 0.28) 0 14%, transparent 15%);
  animation: blobFloat 11s ease-in-out infinite alternate;
}

@keyframes skyShift {
  from { filter: hue-rotate(0deg) saturate(1); }
  to { filter: hue-rotate(12deg) saturate(1.08); }
}
@keyframes blobFloat {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-2%, 3%, 0) scale(1.06); }
}

button, input, select, textarea { font: inherit; color: inherit; }

.app {
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(255, 45, 106, 0.12);
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(110deg, var(--accent) 0%, var(--accent-2) 55%, #ff9f1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.online {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(18, 185, 129, 0.25);
}
.online .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulseDot 1.6s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.75; }
}

/* Home */
.home {
  flex: 1;
  overflow-y: auto;
  padding: 22px 18px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.home h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 700;
  background: linear-gradient(120deg, #ff1f62 0%, #ff6b2c 40%, #19d4e6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleIn 0.7s cubic-bezier(.2, .9, .2, 1) both;
}
.tagline {
  color: var(--muted);
  margin-top: -8px;
  font-size: 16px;
  font-weight: 700;
  animation: titleIn 0.7s 0.08s cubic-bezier(.2, .9, .2, 1) both;
}
@keyframes titleIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 0 rgba(255, 45, 106, 0.08);
}
.label {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  flex: 1 1 0;
  min-width: 64px;
  padding: 12px 10px;
  border-radius: 14px;
  border: 2px solid rgba(255, 45, 106, 0.14);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
  font-family: var(--font-display);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip:active { transform: scale(0.96); }
.chip.active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transform: translateY(-1px);
}
.chips.invalid .chip { border-color: var(--danger); }

.select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 45, 106, 0.14);
  background: #fff;
  appearance: none;
  font-weight: 700;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.hint { font-size: 13px; color: var(--muted); margin-top: -2px; font-weight: 600; }
.form-hint { color: var(--danger); font-size: 14px; font-weight: 700; }
.banned-note { color: var(--danger); font-size: 15px; text-align: center; font-weight: 700; }

.home-search {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  border: 2px dashed rgba(255, 45, 106, 0.35);
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-weight: 700;
}
.home-search .spinner {
  width: 20px; height: 20px;
  border: 3px solid rgba(255, 45, 106, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 16px;
  border: 2px solid transparent;
  font-weight: 800;
  font-family: var(--font-display);
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:not(:disabled):active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 0 #d91b52;
}
.btn-primary:not(:disabled):active { box-shadow: 0 3px 0 #d91b52; transform: translateY(4px); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 45, 106, 0.2);
  color: var(--text);
}
.btn-report {
  background: #fff;
  border-color: rgba(225, 29, 72, 0.35);
  color: var(--danger);
}
.btn-big {
  width: 100%;
  padding: 18px;
  font-size: 20px;
  margin-top: 2px;
  letter-spacing: -0.01em;
  animation: ctaPulse 2.4s ease-in-out infinite;
}

.legal-links {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.legal-links a {
  color: var(--accent);
  text-decoration: none;
}
.rules-legal {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.4;
}
.rules-legal a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}
@keyframes ctaPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.06); }
}

/* Chat */
.chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.45);
}
.chat[hidden],
.home[hidden],
.home-search[hidden],
#cancel-search-btn[hidden],
#home-hint[hidden],
#banned-note[hidden],
#typing[hidden],
.toast[hidden],
.modal[hidden] { display: none !important; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 2px solid rgba(255, 45, 106, 0.12);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 0;
  font-weight: 800;
  font-family: var(--font-display);
}
.status { color: var(--muted); flex: 1; text-align: center; font-weight: 700; }
.status.connected { color: var(--ok); }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overscroll-behavior: contain;
}

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
  font-weight: 600;
  animation: msgIn 0.25s ease both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.msg.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.peer {
  align-self: flex-start;
  background: var(--peer);
  border: 2px solid rgba(25, 212, 230, 0.35);
  border-bottom-left-radius: 6px;
  color: var(--text);
}
.msg.pending { opacity: 0.6; }
.msg.img { padding: 4px; background: transparent; border: 2px solid rgba(255, 45, 106, 0.2); }
.msg.img img { display: block; max-width: 240px; max-height: 320px; border-radius: 14px; }
.msg .expired {
  display: block;
  padding: 18px 16px;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

.sys {
  align-self: center;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(255, 210, 58, 0.55);
  border-radius: 12px;
  padding: 8px 12px;
  max-width: 92%;
}
.sys.warn { color: #b45309; border-color: rgba(255, 180, 0, 0.55); }

.searching {
  margin: auto;
  display: grid;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  font-weight: 700;
}
.spinner {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 4px solid rgba(255, 45, 106, 0.18);
  border-top-color: var(--accent);
  border-right-color: var(--cyan);
  animation: spin 0.85s linear infinite;
}

.typing { padding: 0 18px 6px; font-size: 13px; color: var(--muted); font-style: italic; font-weight: 700; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 4px;
  border-top: 2px solid rgba(255, 45, 106, 0.12);
  background: rgba(255, 255, 255, 0.75);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 2px solid rgba(255, 45, 106, 0.16);
  background: #fff;
  outline: none;
  font-weight: 600;
}
.composer textarea:focus { border-color: var(--accent); }
.composer textarea:disabled { opacity: 0.5; }

.photo-btn, .send-btn {
  position: relative;
  flex: 0 0 46px;
  width: 46px; height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  border: 2px solid rgba(255, 45, 106, 0.16);
  background: #fff;
  cursor: pointer;
}
.send-btn {
  background: linear-gradient(135deg, var(--cyan), #2b8cff);
  border-color: transparent;
  color: #fff;
}
.send-btn:disabled { opacity: 0.5; }
.photo-btn.locked { color: var(--muted); opacity: 0.55; cursor: not-allowed; }
.lock-count {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--sun);
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 11px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  color: #1a1020;
}
.lock-count:empty { display: none; }

.lock-hint { padding: 0 16px 4px; font-size: 12px; color: var(--muted); min-height: 18px; font-weight: 700; }

.actions {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.75);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(40, 10, 30, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, #fff 0%, #fff7fb 100%);
  border: 2px solid rgba(255, 45, 106, 0.18);
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
}
.modal-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin-bottom: 14px;
  color: var(--accent);
}
.modal-card ul { display: grid; gap: 8px; padding-left: 18px; margin-bottom: 14px; }
.modal-card li { font-size: 15px; font-weight: 600; }
.agree {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 16px;
  border: 2px solid rgba(255, 45, 106, 0.2);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}
.agree input { width: 22px; height: 22px; flex: 0 0 22px; accent-color: var(--accent); margin-top: 1px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  max-width: 90vw;
  padding: 12px 16px;
  border-radius: 14px;
  background: #1a1020;
  color: #fff;
  border: 2px solid var(--accent);
  font-size: 14px;
  font-weight: 700;
}

@media (min-width: 700px) {
  .app {
    border-left: 2px solid rgba(255, 45, 106, 0.12);
    border-right: 2px solid rgba(255, 45, 106, 0.12);
    background: rgba(255, 255, 255, 0.25);
  }
  .modal { align-items: center; }
  .modal-card { border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
