/* ============================================================
   MEIWORD CHAT ROLEPLAY — WhatsApp-style conversation practice
   Cream + indigo identity, mobile-first chat shell.
   ============================================================ */

:root {
  --ink: #1e1b4b;
  --indigo: #6366f1;
  --indigo-dark: #4338ca;
  --indigo-soft: #eef2ff;
  --gold: #f59e0b;
  --gold-soft: #fef3c7;
  --mint: #10b981;
  --mint-soft: #d1fae5;
  --rose: #f43f5e;
  --rose-soft: #ffe4e6;
  --bg: #fdfbf7;
  --card: #ffffff;
  --muted: #6b7280;
  --line: #e9e7f5;
  --nav-height: 60px;
}

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

html, body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  background-image: radial-gradient(#e7e4f7 1.1px, transparent 1.1px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: 'Bricolage Grotesque', 'Inter', sans-serif; }

a { color: inherit; }
button { font-family: inherit; }

/* ---------- top nav ---------- */
.chat-top-nav {
  position: sticky; top: 0; z-index: 40;
  height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(253, 251, 247, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.12rem; }
.brand-badge {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-badge svg { width: 18px; height: 18px; }
.nav-link { font-size: 0.88rem; font-weight: 600; color: var(--indigo-dark); text-decoration: none; }
.nav-link:hover { text-decoration: underline; }
.nav-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.02rem; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.92rem; color: var(--ink); text-decoration: none; }
.back-link svg { width: 18px; height: 18px; }

/* ---------- layout ---------- */
.wrap { max-width: 940px; margin: 0 auto; padding: 26px 16px 50px; position: relative; z-index: 1; }
.wrap-play { max-width: 620px; }

/* ---------- hero / index ---------- */
.kicker {
  display: inline-block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em;
  color: var(--indigo-dark); background: var(--indigo-soft);
  padding: 5px 11px; border-radius: 999px; margin-bottom: 12px;
}
.hero h1 { font-size: clamp(2.1rem, 7vw, 3rem); font-weight: 800; line-height: 1.05; }
.hero h1 .hl { color: var(--indigo); }
.hero p { margin-top: 10px; color: var(--muted); font-size: 1rem; line-height: 1.55; max-width: 58ch; }

/* ---------- scenario cards ---------- */
.scen-grid { display: grid; gap: 16px; margin-top: 26px; }
@media (min-width: 720px) { .scen-grid { grid-template-columns: 1fr 1fr; } }

.scen-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 18px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 10px 26px rgba(30, 27, 75, 0.06); text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.scen-card:hover { transform: translateY(-3px); box-shadow: 0 16px 32px rgba(30, 27, 75, 0.1); }

.scen-top { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  color: #fff; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.25rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.scen-head-text { flex: 1; min-width: 0; }
.scen-head-text h2 { font-size: 1.16rem; font-weight: 800; line-height: 1.25; }
.scen-npc { font-size: 0.82rem; color: var(--muted); margin-top: 1px; }

.lock-chip {
  flex: none; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em;
  padding: 5px 9px; border-radius: 999px;
}
.lock-chip.free { background: var(--mint-soft); color: #047857; }
.lock-chip.premium { background: var(--gold-soft); color: #92400e; }

.scen-sub { font-weight: 700; font-size: 0.94rem; color: var(--indigo-dark); }
.scen-desc { color: var(--muted); font-size: 0.9rem; line-height: 1.55; flex: 1; }

.scen-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.meta-chip {
  font-size: 0.74rem; font-weight: 700; color: var(--indigo-dark);
  background: var(--indigo-soft); padding: 4px 10px; border-radius: 999px;
}
.best-chip { font-size: 0.8rem; font-weight: 800; color: #b45309; }
.best-chip:empty { display: none; }

/* ---------- note & footer ---------- */
.note-strip {
  margin-top: 22px; display: flex; gap: 9px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; font-size: 0.86rem; line-height: 1.5; color: var(--muted);
}
.note-strip svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--rose); }

.chat-footer {
  border-top: 1px solid var(--line); padding: 22px 16px 30px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 0.85rem; color: var(--muted); text-align: center;
}
.chat-footer a { color: var(--indigo-dark); font-weight: 600; text-decoration: none; }
.chat-footer a:hover { text-decoration: underline; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.96rem; font-weight: 700;
  padding: 13px 18px; border-radius: 14px; border: none; cursor: pointer;
  text-decoration: none; transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
  color: #fff; box-shadow: 0 8px 18px rgba(67, 56, 202, 0.28);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--indigo); }
.btn-gold { background: var(--gold); color: #451a03; box-shadow: 0 8px 18px rgba(245, 158, 11, 0.3); }
.btn-gold:hover { transform: translateY(-1px); }

/* ---------- overlay cards (start / end) ---------- */
.stage-wrap { position: relative; }
.overlay-card {
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  padding: 26px 22px; text-align: center;
  box-shadow: 0 10px 26px rgba(30, 27, 75, 0.06);
}
.overlay-card h2 { font-size: 1.45rem; font-weight: 800; line-height: 1.25; }
.start-avatar {
  width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 13px;
  color: #fff; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
}
.start-sub { color: var(--muted); font-size: 0.88rem; margin-top: 5px; }
.start-scene { color: var(--ink); font-size: 0.94rem; line-height: 1.6; margin: 14px auto 18px; max-width: 46ch; }
.start-hint { color: var(--muted); font-size: 0.8rem; line-height: 1.5; margin-top: 13px; }

.win-stars { display: flex; justify-content: center; gap: 5px; margin-bottom: 10px; }
.win-stars .star { width: 38px; height: 38px; fill: #e5e2f2; }
.win-stars .star.on { fill: var(--gold); }
.result-stats { font-weight: 800; color: var(--indigo-dark); margin-top: 7px; font-size: 0.98rem; }
.end-text { color: var(--muted); font-size: 0.93rem; line-height: 1.6; margin: 10px auto 0; max-width: 48ch; }
.end-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }

.cta-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  background: var(--indigo-soft); border: 1px solid #dfe3fb; border-radius: 14px;
  padding: 13px 15px; margin-top: 14px; text-decoration: none;
}
.cta-card b { color: var(--ink); font-size: 0.95rem; }
.cta-card span { color: var(--muted); font-size: 0.85rem; }

/* ---------- recap ---------- */
.recap-wrap { text-align: left; margin-top: 20px; }
.recap-wrap h3 { font-size: 0.98rem; font-weight: 800; margin-bottom: 10px; }
.recap-item {
  border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 9px; background: #fff;
}
.recap-npc { font-size: 0.82rem; color: var(--muted); line-height: 1.5; margin-bottom: 6px; }
.recap-pick { font-size: 0.92rem; line-height: 1.5; margin-bottom: 4px; font-weight: 600; }
.recap-pick.bad { color: #b91c1c; }
.recap-pick.mid { color: #92400e; }
.recap-best { font-size: 0.92rem; line-height: 1.5; color: #047857; font-weight: 700; }
.recap-note { font-size: 0.85rem; color: var(--muted); line-height: 1.55; margin-top: 6px; }
.perfect-line {
  background: var(--mint-soft); color: #065f46; font-weight: 700; font-size: 0.92rem;
  border-radius: 14px; padding: 12px 14px; text-align: center; line-height: 1.5;
}

/* ---------- chat shell ---------- */
.chat-shell {
  display: flex; flex-direction: column;
  height: min(660px, calc(100dvh - 148px)); min-height: 460px;
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  overflow: hidden; box-shadow: 0 10px 26px rgba(30, 27, 75, 0.06);
}
.chat-head {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fff; flex: none;
}
.chat-head .avatar { width: 40px; height: 40px; font-size: 1.05rem; }
.chat-head-text { display: flex; flex-direction: column; min-width: 0; }
.npc-name { font-weight: 800; font-size: 0.98rem; }
.npc-role { font-size: 0.78rem; color: var(--muted); }
.mute-btn {
  margin-left: auto; flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--indigo-dark);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.mute-btn svg { width: 19px; height: 19px; }

.progress-track { height: 5px; background: var(--indigo-soft); flex: none; }
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--indigo), var(--indigo-dark));
  transition: width 0.4s ease;
}

.chat-body {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 9px;
  background: var(--bg);
  background-image: radial-gradient(#e7e4f7 1.1px, transparent 1.1px);
  background-size: 22px 22px;
}
.scene-note {
  align-self: center; max-width: 94%;
  background: #fff; border: 1px dashed #cfd2ee; border-radius: 12px;
  color: var(--muted); font-size: 0.8rem; line-height: 1.55;
  padding: 9px 13px; text-align: center;
}

.msg-row { display: flex; }
.msg-row.me { justify-content: flex-end; }
.bubble {
  max-width: 84%; padding: 10px 13px; border-radius: 16px;
  font-size: 0.95rem; line-height: 1.5; overflow-wrap: break-word;
}
.bubble-npc {
  background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px;
  display: flex; gap: 8px; align-items: flex-start;
  box-shadow: 0 3px 8px rgba(30, 27, 75, 0.04);
}
.bubble-me {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
  color: #fff; border-bottom-right-radius: 6px;
  box-shadow: 0 3px 8px rgba(67, 56, 202, 0.2);
}
.speak-btn {
  flex: none; width: 26px; height: 26px; border-radius: 50%; margin-top: 1px;
  border: 1px solid var(--line); background: var(--indigo-soft); color: var(--indigo-dark);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.speak-btn svg { width: 14px; height: 14px; }

.bubble.typing { display: flex; gap: 4px; align-items: center; padding: 14px 13px; }
.tdot {
  width: 7px; height: 7px; border-radius: 50%; background: #b6bce8;
  animation: tblink 1s infinite;
}
.tdot:nth-child(2) { animation-delay: 0.15s; }
.tdot:nth-child(3) { animation-delay: 0.3s; }
@keyframes tblink {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- choices dock ---------- */
.choices {
  flex: none; border-top: 1px solid var(--line); background: #fff;
  padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px;
}
.choices:empty { display: none; }
.choices-label { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.choice-btn {
  text-align: left; background: var(--indigo-soft); border: 1.5px solid #dfe3fb;
  color: var(--ink); font-size: 0.93rem; line-height: 1.45;
  padding: 11px 13px; border-radius: 14px; cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.1s ease;
}
.choice-btn:hover { border-color: var(--indigo); background: #e3e8fd; transform: translateY(-1px); }
.choice-btn:active { transform: translateY(1px); }
