/* ============================================================
   MEIWORD SENTENCE BUILDER — word-tile sentence puzzles
   Cream + indigo identity, mobile-first.
   ============================================================ */

:root {
  --ink: #1e1b4b;
  --indigo: #6366f1;
  --indigo-dark: #4338ca;
  --indigo-soft: #eef2ff;
  --gold: #f59e0b;
  --gold-soft: #fef3c7;
  --mint: #10b981;
  --mint-soft: #d1fae5;
  --rose: #f43f5e;
  --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 ---------- */
.bld-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: 640px; }

/* ---------- 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; }

/* ---------- pack cards ---------- */
.pack-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }

.pack-card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 20px;
  padding: 16px 18px; display: flex; flex-direction: row; flex-wrap: wrap; align-items: center;
  column-gap: 14px; row-gap: 6px;
  box-shadow: 0 4px 14px rgba(30, 27, 75, 0.05); text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.1s ease;
}
.pack-card:hover { transform: translateY(-1px); border-color: var(--indigo); box-shadow: 0 10px 22px rgba(30, 27, 75, 0.08); }
.pack-top { flex: 1 1 230px; }
.pack-sub { flex: 1 1 100%; }
.pack-desc { flex: 1 1 100%; }
.pack-meta { flex: 1 1 auto; }
.pack-card::after {
  content: "Main"; flex: 0 0 auto; margin-left: auto;
  background: var(--gold); color: #231a04; font-weight: 800; font-size: 0.85rem;
  border-radius: 999px; padding: 9px 18px; box-shadow: 0 3px 0 #d97706;
}

.pack-top { display: flex; align-items: center; gap: 12px; }
.pack-dot {
  width: 46px; height: 46px; border-radius: 14px; 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;
}
.pack-head-text { flex: 1; min-width: 0; }
.pack-head-text h2 { font-size: 1.16rem; font-weight: 800; line-height: 1.25; }
.pack-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; }

.pack-sub { font-weight: 700; font-size: 0.94rem; color: var(--indigo-dark); }
.pack-desc { color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.pack-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); }

.bld-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;
}
.bld-footer a { color: var(--indigo-dark); font-weight: 600; text-decoration: none; }
.bld-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-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-dot {
  width: 74px; height: 74px; border-radius: 22px; 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-desc { 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-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; }

/* ---------- review ---------- */
.review-wrap { text-align: left; margin-top: 20px; }
.review-wrap h3 { font-size: 0.98rem; font-weight: 800; margin-bottom: 10px; }
.review-item {
  border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 13px; margin-bottom: 9px; background: #fff;
}
.review-en { font-size: 0.94rem; font-weight: 700; line-height: 1.5; }
.review-id { font-size: 0.86rem; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.review-note { font-size: 0.83rem; color: #047857; line-height: 1.55; margin-top: 5px; }

/* ---------- game area ---------- */
.game-area {
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  padding: 18px; box-shadow: 0 10px 26px rgba(30, 27, 75, 0.06);
}
.hud-row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.hud-pill {
  font-size: 0.8rem; font-weight: 800; color: var(--indigo-dark);
  background: var(--indigo-soft); padding: 5px 11px; border-radius: 999px;
}
.hud-mistakes { background: var(--gold-soft); color: #92400e; }
.progress-track { height: 5px; background: var(--indigo-soft); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--indigo), var(--indigo-dark));
  transition: width 0.4s ease;
}

.meaning-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; text-align: center; margin-bottom: 14px;
}
.meaning-label { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.1em; color: var(--muted); }
.meaning-text { font-size: 1.14rem; font-weight: 800; line-height: 1.45; margin-top: 5px; }
.hear-btn {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.84rem; font-weight: 700; color: var(--indigo-dark);
  background: #fff; border: 1.5px solid #dfe3fb; border-radius: 999px;
  padding: 8px 14px; cursor: pointer;
}
.hear-btn:hover { border-color: var(--indigo); }
.hear-btn svg { width: 16px; height: 16px; }

.answer-zone {
  min-height: 66px; border: 2px dashed #cfd2ee; border-radius: 16px;
  padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  background: #fbfbff; margin-bottom: 12px;
}
.answer-placeholder { color: var(--muted); font-size: 0.88rem; line-height: 1.5; padding: 6px 2px; }
.answer-zone.shake { animation: shake 0.4s ease; border-color: var(--rose); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.tile-bank {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  min-height: 48px; margin-bottom: 6px;
}
.tile {
  font-size: 1rem; font-weight: 700; line-height: 1.2;
  padding: 11px 15px; border-radius: 12px; cursor: pointer;
  background: #fff; color: var(--ink);
  border: 1.5px solid var(--line); border-bottom-width: 3px;
  transition: transform 0.1s ease, background 0.12s ease, border-color 0.12s ease;
}
.tile:hover { border-color: var(--indigo); transform: translateY(-1px); }
.tile:active { transform: translateY(1px); }
.tile.in-answer {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
  color: #fff; border-color: var(--indigo-dark);
}

.feedback-line {
  min-height: 1.4em; text-align: center;
  font-size: 0.88rem; font-weight: 600; color: #b45309;
  line-height: 1.5; margin: 6px 0 10px;
}
.game-actions { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }

.solved-banner {
  margin-top: 16px; background: var(--mint-soft); border: 1px solid #a7f3d0;
  border-radius: 16px; padding: 16px; text-align: center;
}
.solved-text { font-size: 1.08rem; font-weight: 800; line-height: 1.5; color: #065f46; }
.solved-note { font-size: 0.88rem; line-height: 1.55; color: #065f46; margin: 7px auto 13px; max-width: 48ch; }
