/* =====================================================
   TETO CHAT — IDIOM QUEST  |  Full Redesign
   Aesthetic: Dark Anime Glassmorphism
   Fonts: Syne (display) + DM Sans (body)
   ===================================================== */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --pink:      #ff6b9d;
  --pink-dim:  #d9547e;
  --purple:    #9b5de5;
  --violet:    #7c3aed;
  --navy:      #090d1a;
  --navy-mid:  #0e1528;
  --navy-card: rgba(14,21,40,0.72);
  --glass:     rgba(255,255,255,0.055);
  --glass-border: rgba(255,255,255,0.10);
  --text:      #f0f2ff;
  --text-muted:#8892b0;
  --correct:   #22d3a5;
  --wrong:     #f06060;
  --speed:     220ms;
  --radius:    20px;
}

html, body {
  height: 100%;
  background: var(--navy);
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Animated Mesh Background ── */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.mesh-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: floatBlob 14s ease-in-out infinite alternate;
}

.mesh-1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, #9b5de5 0%, transparent 65%);
  top: -100px; left: -100px;
  animation-duration: 16s;
}
.mesh-2 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, #ff6b9d 0%, transparent 65%);
  bottom: -60px; right: -80px;
  animation-duration: 12s;
  animation-delay: -4s;
}
.mesh-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #7c3aed 0%, transparent 65%);
  top: 40%; left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 18s;
  animation-delay: -8s;
}

@keyframes floatBlob {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, -20px) scale(1.07); }
  100% { transform: translate(-15px, 30px) scale(0.96); }
}

/* ── Phone Shell ── */
.phone-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 440px;
  margin: 0 auto;
  background: var(--navy-card);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-left: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  overflow: hidden;
}

@media (min-height: 800px) {
  .phone-shell {
    max-width: 420px;
    height: min(820px, 100vh);
    margin: auto;
    border-radius: 32px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 40px 100px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.08);
  }
  html, body { display: flex; align-items: center; justify-content: center; }
}

/* ── Status Bar ── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 6px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
}

.status-icons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.s-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Chat Header ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 14px;
  background: rgba(9,13,26,0.6);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.back-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: color var(--speed), background var(--speed);
  flex-shrink: 0;
}
.back-btn:hover { color: var(--text); background: var(--glass); }
.back-btn svg { width: 20px; height: 20px; }

/* Avatar */
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.avatar-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.avatar-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(var(--pink), var(--purple), var(--pink));
  animation: spinRing 4s linear infinite;
}

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

.avatar-img {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  object-fit: cover;
  background: #1a0d2e;
}

.header-info { min-width: 0; }

.header-name {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--correct);
  box-shadow: 0 0 6px var(--correct);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* HUD */
.game-hud {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.hud-hearts {
  display: flex;
  gap: 3px;
}

.heart-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.3s, opacity 0.3s;
}

.heart-icon.lost {
  opacity: 0.2;
  filter: grayscale(1);
}

.hud-score {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.score-label {
  font-family: 'Syne', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--pink);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.score-value {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  min-width: 28px;
  text-align: right;
  transition: transform 0.3s;
}

.score-value.bump {
  animation: scoreBump 0.4s cubic-bezier(0.3, 1.5, 0.6, 1);
}
@keyframes scoreBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); color: var(--pink); }
  100% { transform: scale(1); }
}

/* ── Chat Body ── */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar { width: 4px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* ── Message Bubbles ── */
.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(18px);
  animation: bubbleIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

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

.bubble-row.teto-row { align-self: flex-start; flex-direction: row; }
.bubble-row.player-row { align-self: flex-end; flex-direction: row-reverse; }

/* mini avatar for teto */
.bubble-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #1a0d2e;
  flex-shrink: 0;
  overflow: hidden;
  align-self: flex-end;
}
.bubble-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bubble {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 0.92rem;
  font-weight: 400;
}

.bubble.teto-bubble {
  background: rgba(40,20,70,0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(155, 93, 229, 0.25);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.bubble.player-bubble {
  background: linear-gradient(135deg, #c2185b, var(--pink));
  border-bottom-right-radius: 4px;
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 107, 157, 0.35);
  font-weight: 500;
}

.bubble.player-bubble strong {
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 1px 3px;
}

/* ── Typing Indicator ── */
.typing-bubble {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  background: rgba(40,20,70,0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(155,93,229,0.2);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple);
  animation: typingDot 1.5s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingDot {
  0%, 80%, 100%  { transform: scale(0.6); opacity: 0.5; }
  40%            { transform: scale(1.2); opacity: 1; background: var(--pink); }
}

/* Date separator */
.date-sep {
  align-self: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 4px 12px;
  letter-spacing: 0.04em;
}

/* ── Chat Footer ── */
.chat-footer {
  flex-shrink: 0;
  background: rgba(9,13,26,0.75);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  padding: 16px;
}

.pick-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Option Buttons */
.opt-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition:
    background var(--speed),
    border-color var(--speed),
    transform 150ms,
    box-shadow var(--speed),
    opacity var(--speed);
  position: relative;
  overflow: hidden;
  line-height: 1.45;
}

/* Shimmer overlay on hover */
.opt-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.06) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.5s;
}
.opt-btn:hover::before { transform: translateX(100%); }

.opt-btn:hover:not(:disabled):not(.opt-wrong):not(.opt-correct) {
  background: rgba(155, 93, 229, 0.15);
  border-color: rgba(155, 93, 229, 0.5);
  box-shadow: 0 0 0 0 transparent, 0 4px 16px rgba(155,93,229,0.25);
  transform: translateY(-1px);
}

.opt-btn:active:not(:disabled) { transform: translateY(0); }

.opt-btn:disabled { cursor: not-allowed; }

/* Option index badge */
.opt-index {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  font-family: 'Syne', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background var(--speed), border-color var(--speed), color var(--speed);
}

/* Correct state */
.opt-btn.opt-correct {
  background: rgba(34, 211, 165, 0.12);
  border-color: var(--correct);
  color: var(--correct);
}
.opt-btn.opt-correct .opt-index {
  background: rgba(34,211,165,0.2);
  border-color: var(--correct);
  color: var(--correct);
}

/* Wrong state */
.opt-btn.opt-wrong {
  background: rgba(240, 96, 96, 0.10);
  border-color: var(--wrong);
  color: var(--wrong);
  animation: shake 0.45s cubic-bezier(.36,.07,.19,.97) both;
}
.opt-btn.opt-wrong .opt-index {
  background: rgba(240,96,96,0.2);
  border-color: var(--wrong);
  color: var(--wrong);
}

/* Eliminated (already tried, wrong) */
.opt-btn.opt-elim {
  opacity: 0.3;
  pointer-events: none;
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

/* ── End Panel ── */
.end-panel {
  text-align: center;
  padding: 8px 0 4px;
}

.end-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 12px currentColor);
}

.end-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.end-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.end-score-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  padding: 8px 20px;
  margin-bottom: 16px;
}

.end-score-label {
  font-family: 'Syne', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--pink);
}

.end-score-val {
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.restart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  border: none;
  border-radius: 50px;
  padding: 13px 28px;
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(155,93,229,0.45);
  width: 100%;
}

.restart-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(155,93,229,0.55);
}

.restart-btn:active { transform: translateY(0); }

/* ── Utility ── */
.hidden { display: none !important; }

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