:root {
  --bg: #08080f;
  --accent: #e040a0;
  --accent2: #00e5ff;
  --accent-glow: rgba(224, 64, 160, 0.35);
  --accent2-glow: rgba(0, 229, 255, 0.25);
  --text: #f0eeff;
  --text-dim: rgba(240, 238, 255, 0.45);
  --bubble-ai: rgba(12, 10, 24, 0.82);
  --bubble-user: rgba(224, 64, 160, 0.18);
  --border: rgba(224, 64, 160, 0.2);
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", sans-serif;
  overflow: hidden;
}

/* ============================================================
   AVATAR LAYER — full screen behind everything
   ============================================================ */
.avatar-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#vrm-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Dark vignette fading bottom 40% — so chat is readable */
.vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 30%,
    rgba(8, 8, 15, 0.55) 55%,
    rgba(8, 8, 15, 0.92) 75%,
    rgba(8, 8, 15, 0.98) 100%
  );
  pointer-events: none;
}

/* Side vignettes */
.vignette::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(8,8,15,0.5) 0%, transparent 20%),
    linear-gradient(to left,  rgba(8,8,15,0.5) 0%, transparent 20%);
}

/* Loading overlay */
.vrm-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  font-family: "Rajdhani", sans-serif;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  z-index: 2;
  transition: opacity 0.8s ease;
}
.vrm-loading.hidden { opacity: 0; pointer-events: none; }

.vrm-loading-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

/* ============================================================
   STAGE BADGE — top left
   ============================================================ */
.stage-badge {
  position: fixed;
  top: 18px; left: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  background: rgba(8, 8, 15, 0.7);
  border: 1px solid var(--border);
  border-radius: 20px;
  backdrop-filter: blur(8px);
  font-family: "Rajdhani", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--accent2);
  text-transform: uppercase;
}

.stage-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 8px var(--accent2);
  animation: pulse 2s ease-in-out infinite;
}

/* ============================================================
   MOOD BADGE — top right
   ============================================================ */
.mood-badge {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  background: rgba(8, 8, 15, 0.7);
  border: 1px solid var(--border);
  border-radius: 20px;
  backdrop-filter: blur(8px);
  font-family: "Rajdhani", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.mood-icon { font-size: 14px; }

/* ============================================================
   CHAT OVERLAY — bottom
   ============================================================ */
.chat-overlay {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  max-height: 52vh;
  padding: 0 0 0;
}

/* Messages scroll area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 2px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 1px;
}

/* Welcome bubble */
.welcome-bubble {
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 0 12px 12px 12px;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  backdrop-filter: blur(6px);
  max-width: 85%;
}

/* Message bubbles */
.msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: msgIn 0.25s ease;
  max-width: 88%;
}

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

.msg.ai   { align-self: flex-start; }
.msg.user { align-self: flex-end; }

.msg-name {
  font-family: "Rajdhani", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0 4px;
}

.msg.ai   .msg-name { color: var(--accent);  }
.msg.user .msg-name { color: var(--accent2); text-align: right; }

.msg-bubble {
  padding: 9px 13px;
  font-size: 13px;
  line-height: 1.6;
  backdrop-filter: blur(8px);
}

.msg.ai .msg-bubble {
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 0 12px 12px 12px;
  color: var(--text);
  box-shadow: 0 0 20px rgba(224, 64, 160, 0.08);
}

.msg.user .msg-bubble {
  background: var(--bubble-user);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-right: 2px solid var(--accent2);
  border-radius: 12px 0 12px 12px;
  color: var(--text);
}

/* Typing indicator */
.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 13px;
}

.typing span {
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing-dot 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================
   INPUT BAR
   ============================================================ */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 16px 20px;
  background: linear-gradient(to top, rgba(8,8,15,0.98) 0%, rgba(8,8,15,0.85) 100%);
  border-top: 1px solid var(--border);
}

textarea {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 13px;
  font-weight: 300;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 100px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

textarea::placeholder { color: var(--text-dim); }

.send-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #a020c0);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 14px var(--accent-glow);
}

.send-btn:hover  { transform: scale(1.06); box-shadow: 0 0 22px var(--accent-glow); }
.send-btn:active { transform: scale(0.94); }
.send-btn svg    { width: 16px; height: 16px; fill: white; }

/* ============================================================
   PARTICLES
   ============================================================ */
.particle {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  animation: particle-rise linear forwards;
  z-index: 999;
}

@keyframes particle-rise {
  0%   { opacity: 0.7; transform: translateY(0) scale(1); }
  100% { opacity: 0;   transform: translateY(-90px) scale(0.2); }
}

/* ============================================================
   NEON SCAN LINE — subtle atmosphere
   ============================================================ */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 100;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ============================================================
   DESKTOP — wider layout, avatar centered
   ============================================================ */
@media (min-width: 768px) {
  .chat-overlay {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    max-height: 45vh;
  }

  .stage-badge { top: 24px; left: 24px; }
  .mood-badge  { top: 24px; right: 24px; }
}

/* Safe area for notch phones */
@supports (padding: max(0px)) {
  .input-bar {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}