/* ============================================================
   MEIWORD MATCH — memory pairs game for kids (word + picture)
   Cream + indigo identity, mobile-first, tactile cards.
   Shares its look with Word Sprint (css/sprint.css).
   ============================================================ */

: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; }

/* ---------- top nav ---------- */
.match-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; }
.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; }
.hud-pill {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font-weight: 800; font-size: 0.9rem;
  display: inline-flex; align-items: center; gap: 6px;
}

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

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

.topic-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }

.topic-card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 20px;
  padding: 14px 16px; box-shadow: 0 4px 14px rgba(30, 27, 75, 0.05);
  text-decoration: none; display: flex; flex-direction: row; align-items: center; gap: 14px;
  transition: transform 0.08s ease, border-color 0.1s ease;
}
.topic-card:hover { border-color: var(--indigo); transform: translateY(-1px); }
.topic-icon {
  flex: 0 0 56px; width: 56px; height: 56px; border-radius: 16px;
  background: var(--indigo-soft); display: flex; align-items: center; justify-content: center;
  font-size: 30px; line-height: 1;
}
.topic-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.topic-card h2 { font-size: 1.05rem; font-weight: 800; line-height: 1.2; color: var(--ink); }
.topic-card .idn { color: var(--muted); font-size: 0.82rem; line-height: 1.35; }
.topic-meta { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.play-pill {
  flex: 0 0 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;
}
@media (max-width: 560px) {
  .topic-icon { flex-basis: 48px; width: 48px; height: 48px; font-size: 26px; border-radius: 14px; }
  .topic-card { padding: 12px 13px; gap: 11px; }
  .play-pill { padding: 8px 13px; font-size: 0.8rem; }
  .topic-meta .count-chip { display: none; }
}
.count-chip { font-size: 0.74rem; font-weight: 700; color: var(--muted); background: #f5f4fa; padding: 3px 9px; border-radius: 999px; }
.free-chip { font-size: 0.74rem; font-weight: 800; color: #92400e; background: var(--gold-soft); padding: 3px 9px; border-radius: 999px; }
.lock-ic { width: 15px; height: 15px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 0.95rem; text-decoration: none;
  border-radius: 13px; padding: 13px 16px; border: 2px solid transparent;
  cursor: pointer; touch-action: manipulation; font-family: inherit;
  transition: transform 0.08s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: var(--indigo); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35); }
.btn-primary:hover { background: var(--indigo-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--indigo); color: var(--indigo-dark); }
.btn svg { width: 17px; height: 17px; flex: none; }

.howto { margin-top: 30px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px; }
.howto h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 12px; }
.howto ol { list-style: none; display: grid; gap: 11px; }
.howto li { display: flex; gap: 11px; align-items: flex-start; font-size: 0.93rem; line-height: 1.5; color: #374151; }
.step-n {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--indigo); color: #fff; font-weight: 800; font-size: 0.8rem;
  display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
}
.note-strip {
  margin-top: 16px; display: flex; gap: 11px; align-items: flex-start;
  background: var(--indigo-soft); border-radius: 16px; padding: 15px 17px;
  font-size: 0.9rem; line-height: 1.5; color: var(--ink);
}
.note-strip svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.foot { margin-top: 30px; text-align: center; color: var(--muted); font-size: 0.82rem; }

/* ---------- play ---------- */
.hud { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.hud-pill .lbl { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.hud-time { margin-left: auto; background: var(--ink); color: #fff; border-color: var(--ink); }

.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mcard {
  perspective: 600px; background: none; border: none; padding: 0;
  aspect-ratio: 3 / 3.3; cursor: pointer; touch-action: manipulation;
  font-family: inherit;
}
.mcard-inner {
  position: relative; display: block; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform 0.38s ease;
}
.mcard.flipped .mcard-inner, .mcard.matched .mcard-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  padding: 6px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.face.back {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22), 0 5px 12px rgba(67, 56, 202, 0.3);
}
.face.back svg { width: 26px; height: 26px; opacity: 0.95; }
.face.front { background: var(--card); border: 2px solid var(--line); transform: rotateY(180deg); }
.mcard.matched { cursor: default; animation: pop 0.3s ease; }
.mcard.matched .face.front { border-color: var(--mint); background: var(--mint-soft); }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.07); } 100% { transform: scale(1); } }
.cword { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: clamp(0.82rem, 3.8vw, 1.05rem); text-align: center; line-height: 1.15; overflow-wrap: anywhere; }
.cword.long { font-size: clamp(0.66rem, 3vw, 0.85rem); }
.cpic { font-size: clamp(30px, 9.5vw, 44px); line-height: 1.1; }

/* ---------- overlays ---------- */
.overlay-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 12px 30px rgba(30, 27, 75, 0.07);
  padding: 30px 22px; text-align: center;
}
.overlay-card h2 { font-size: 1.6rem; font-weight: 800; }
.overlay-card p { color: var(--muted); line-height: 1.55; margin: 10px auto 20px; max-width: 42ch; }
.overlay-card .btn { min-width: 180px; }
.start-icon { font-size: 58px; line-height: 1.2; }
.seg { display: inline-flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; justify-content: center; }
.seg button {
  font-family: inherit; font-weight: 700; font-size: 0.9rem;
  padding: 10px 16px; border-radius: 999px; cursor: pointer; touch-action: manipulation;
  background: #fff; border: 2px solid var(--line); color: var(--ink);
}
.seg button.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.win-stars { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; }
.star { width: 40px; height: 40px; }
.star path { fill: #e5e7eb; }
.star.on path { fill: var(--gold); }
.result-stats { color: #374151; font-weight: 600; }
.result-actions { display: grid; gap: 9px; margin-top: 22px; }
.cta-card {
  display: block; margin-top: 14px; text-align: left; text-decoration: none;
  background: var(--gold-soft); border: 1px solid #fde68a; border-radius: 16px; padding: 15px 17px;
}
.cta-card b { display: block; font-size: 0.97rem; margin-bottom: 3px; }
.cta-card span { font-size: 0.88rem; color: #78716c; line-height: 1.45; }

/* emoji rendering: one Android set via webfont; Apple devices use their
   native set (class set by the <head> detect script — see match pages). */
.match-emoji, .cpic, .topic-icon, .start-icon {
  font-family: 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}
html.apple-emoji .match-emoji,
html.apple-emoji .cpic,
html.apple-emoji .topic-icon,
html.apple-emoji .start-icon {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}
