:root {
  color-scheme: dark;
  --bg: #08080c;
  --card: #15151f;
  --card-soft: #1d1d2b;
  --text: #f7f2ff;
  --muted: #b9b0c8;
  --accent: #ffd84a;
  --accent-soft: rgba(255, 216, 74, 0.18);
  --user: #2bd47d;
  --border: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 216, 74, 0.14), transparent 34%),
    radial-gradient(circle at bottom left, rgba(43, 212, 125, 0.1), transparent 30%),
    var(--bg);
  transition: all 0.3s ease;
}

body.corruption {
  animation: flicker 0.5s infinite alternate;
  background:
    radial-gradient(circle at top, rgba(255, 107, 138, 0.2), transparent 40%),
    radial-gradient(circle at bottom, rgba(138, 43, 226, 0.15), transparent 35%),
    var(--bg);
}

body.exploded {
  background: #000;
  animation: glitch 0.3s infinite;
}

@keyframes flicker {
  0% { filter: hue-rotate(0deg) brightness(1); }
  25% { filter: hue-rotate(-10deg) brightness(1.1); }
  50% { filter: hue-rotate(10deg) brightness(0.9); }
  75% { filter: hue-rotate(-5deg) brightness(1.05); }
  100% { filter: hue-rotate(0deg) brightness(1); }
}

@keyframes glitch {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

.shell {
  width: min(100% - 32px, 440px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 0 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.chat-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent), var(--card);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--card-soft);
  border-bottom: 1px solid var(--border);
}

.smiley {
  position: relative;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 28px rgba(255, 216, 74, 0.35);
  transition: all 0.3s ease;
}

body.corruption .smiley,
body.exploded .smiley {
  background: #ff6b8a;
  box-shadow: 0 0 40px rgba(255, 107, 138, 0.6);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.smiley::before,
.smiley::after {
  content: "";
  position: absolute;
  top: 19px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #111;
}

.smiley::before {
  left: 15px;
}

.smiley::after {
  right: 15px;
}

.eye {
  display: none;
}

.mouth {
  position: absolute;
  left: 50%;
  bottom: 13px;
  width: 22px;
  height: 11px;
  border-bottom: 3px solid #111;
  border-radius: 0 0 24px 24px;
  transform: translateX(-50%);
  transition: all 0.3s ease;
}

body.corruption .mouth,
body.exploded .mouth {
  border-bottom-color: #ff6b8a;
  border-radius: 24px;
  height: 14px;
  box-shadow: 0 0 10px rgba(255, 107, 138, 0.5);
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.chat-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.chat-log {
  height: 420px;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  width: 100%;
  animation: bubbleIn 180ms ease-out both;
}

.message.user {
  justify-content: flex-end;
}

.message.verity {
  justify-content: flex-start;
}

.bubble {
  max-width: 86%;
  padding: 12px 13px;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
}

.message.verity .bubble {
  border-top-left-radius: 5px;
  background: var(--accent-soft);
  border: 1px solid rgba(255, 216, 74, 0.28);
}

.message.user .bubble {
  border-top-right-radius: 5px;
  background: rgba(43, 212, 125, 0.18);
  border: 1px solid rgba(43, 212, 125, 0.28);
}

.meta {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.message.user .meta {
  color: var(--user);
  text-align: right;
}

.status {
  min-height: 22px;
  margin: 0;
  padding: 0 18px 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.status.error {
  color: #ff6b8a;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  padding: 13px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  font: inherit;
}

input:focus {
  border-color: rgba(255, 216, 74, 0.7);
  box-shadow: 0 0 0 4px rgba(255, 216, 74, 0.12);
}

button {
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  color: #111;
  background: var(--accent);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
}

.footer a:hover {
  text-decoration: underline;
}

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

@media (max-width: 480px) {
  .shell {
    width: min(100% - 20px, 440px);
    padding: 24px 0 18px;
  }

  .chat-log {
    height: 58vh;
  }

  .bubble {
    max-width: 92%;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  button {
    min-height: 46px;
  }
}
