:root {
  --bg: #14121a;
  --panel: #1e1b26;
  --panel-hi: #2a2635;
  --text: #ede9e3;
  --muted: #8b8794;
  --line: #322e3d;

  --angry: #e6483a;
  --funny: #f4c744;
  --sad: #5b7cf0;

  --mood: var(--funny);

  --font-display: "Fraunces", serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  width: 100%;
}

/* ===================== SELECT SCREEN ===================== */

#select-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6vh 6vw;
}

.select-wrap {
  max-width: 920px;
  width: 100%;
  text-align: center;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.hero-title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.08;
  margin: 0 0 1.2rem;
  letter-spacing: -0.01em;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 480px;
  margin: 0 auto 3.5rem;
  line-height: 1.6;
}

.dials {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  flex-wrap: wrap;
}

.dial {
  --mood: var(--funny);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  width: 220px;
  padding: 2.4rem 1.5rem 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--text);
  transition: transform 0.35s cubic-bezier(.2,.9,.3,1.2), border-color 0.35s, box-shadow 0.35s;
  position: relative;
}

.dial:hover {
  transform: translateY(-6px) rotate(-1deg);
  border-color: var(--mood);
  box-shadow: 0 18px 40px -20px var(--mood);
}

.dial:nth-child(2):hover { transform: translateY(-6px) rotate(1deg); }

.dial-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin-top: 1.4rem;
}

.dial-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
  line-height: 1.4;
}

/* mood blobs, shared base */
.dial-blob, .avatar-blob {
  width: 64px;
  height: 64px;
  background: var(--mood);
  display: inline-block;
}

.avatar-blob { width: 40px; height: 40px; flex-shrink: 0; }

/* angry: jagged, sharp shard */
.blob-angry {
  clip-path: polygon(50% 0%, 65% 20%, 100% 15%, 78% 42%, 100% 65%,
                      68% 60%, 55% 100%, 42% 62%, 5% 72%, 25% 42%,
                      0% 18%, 38% 25%);
  animation: shake 1.8s ease-in-out infinite;
}

/* funny: bouncy, ever-changing blob */
.blob-funny {
  border-radius: 42% 58% 65% 35% / 45% 40% 60% 55%;
  animation: wobble 3.2s ease-in-out infinite;
}

/* sad: drooping teardrop */
.blob-sad {
  border-radius: 50% 50% 50% 0% / 50% 50% 60% 40%;
  transform: rotate(45deg);
  animation: droop 4s ease-in-out infinite;
}

@keyframes shake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  20% { transform: rotate(-6deg) scale(1.03); }
  40% { transform: rotate(5deg) scale(0.98); }
  60% { transform: rotate(-3deg) scale(1.02); }
  80% { transform: rotate(2deg) scale(1); }
}

@keyframes wobble {
  0%, 100% { border-radius: 42% 58% 65% 35% / 45% 40% 60% 55%; }
  33% { border-radius: 60% 40% 35% 65% / 55% 65% 35% 45%; }
  66% { border-radius: 35% 65% 55% 45% / 40% 50% 50% 60%; }
}

@keyframes droop {
  0%, 100% { transform: rotate(45deg) translateY(0); }
  50% { transform: rotate(48deg) translateY(4px); }
}

/* ===================== CHAT SCREEN ===================== */

#chat-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

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

.chat-identity {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.chat-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0;
}

.chat-status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--mood);
  margin: 0.15rem 0 0;
  text-transform: lowercase;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.ghost-btn:hover {
  border-color: var(--mood);
  color: var(--text);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.msg {
  max-width: 78%;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.95rem;
  animation: rise 0.25s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  background: var(--panel-hi);
  border-bottom-right-radius: 4px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--mood);
  border-bottom-left-radius: 4px;
}

.msg.thinking {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 0.9rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--mood);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mood);
  animation: pulse 1s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

.chat-form {
  display: flex;
  gap: 0.7rem;
  padding: 1.1rem 1.5rem 1.4rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

#chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus {
  border-color: var(--mood);
}

.send-btn {
  background: var(--mood);
  color: #14121a;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0 1.4rem;
  border-radius: 12px;
  cursor: pointer;
  transition: filter 0.2s, transform 0.15s;
}

.send-btn:hover { filter: brightness(1.08); }
.send-btn:active { transform: scale(0.96); }

@media (max-width: 640px) {
  .dials { flex-direction: column; align-items: center; }
  .dial { width: 100%; max-width: 320px; }
  #chat-screen { border: none; }
}

@media (prefers-reduced-motion: reduce) {
  .blob-angry, .blob-funny, .blob-sad, .dot, .msg { animation: none; }
}
