:root {
  --primary: #512b81;
  --primary-2: #7646a8;
  --accent: #f3b51b;
  --bg: #f5f3fa;
  --card: #ffffff;
  --text: #201b2c;
  --muted: #6c6678;
  --line: #e4deee;
  --success: #167a55;
  --danger: #b42318;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans Devanagari", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; padding-bottom: 90px; }
button, input, select { font: inherit; }
button { border: 0; border-radius: 14px; background: var(--primary); color: white; padding: 12px 18px; cursor: pointer; font-weight: 700; }
button:hover { transform: translateY(-1px); }
button.secondary { background: #eee8f6; color: var(--primary); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px max(18px, calc((100vw - 1100px)/2)); background: rgba(81,43,129,.96); color: white; box-shadow: 0 6px 20px rgba(37,21,55,.16); }
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.25rem, 3vw, 1.8rem); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-weight: 800; font-size: .72rem; opacity: .75; margin: 0; }
.voice-main { background: var(--accent); color: #291b00; white-space: nowrap; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 18px; }
.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: .4; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: 0 10px 30px rgba(44,24,70,.06); margin-bottom: 18px; }
.hero { display: grid; grid-template-columns: 1.7fr .8fr; align-items: center; min-height: 300px; background: linear-gradient(135deg, #fff, #eee6fa); }
.hero h2 { font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.08; margin: 12px 0; }
.hero p { color: var(--muted); max-width: 680px; font-size: 1.08rem; }
.hero-icon { font-size: clamp(4rem, 11vw, 8rem); text-align: center; }
.badge { display: inline-block; background: #e5f7ef; color: var(--success); border-radius: 999px; padding: 7px 11px; font-size: .82rem; font-weight: 800; }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.button-row.center { justify-content: center; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stats-grid article { display: flex; flex-direction: column; text-align: center; }
.stats-grid strong { font-size: 2.4rem; color: var(--primary); }
.stats-grid span { color: var(--muted); }
.warning { border-left: 6px solid var(--accent); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 8px 0 18px; }
.section-heading h2 { margin: 4px 0 0; font-size: clamp(1.7rem, 4vw, 2.6rem); }
.search-card { display: grid; grid-template-columns: 1fr 220px; gap: 12px; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 13px 14px; background: white; color: var(--text); }
input:focus, select:focus { outline: 3px solid rgba(81,43,129,.16); border-color: var(--primary); }
.word-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.word-card { background: white; border: 1px solid var(--line); border-radius: 19px; padding: 18px; box-shadow: 0 8px 20px rgba(44,24,70,.05); }
.word-card h3 { font-size: 1.55rem; margin: 0 0 5px; color: var(--primary); }
.word-card p { margin: 6px 0; }
.word-card .meta { color: var(--muted); font-size: .86rem; }
.word-card .status { display: inline-block; border-radius: 999px; font-size: .72rem; padding: 4px 8px; background: #fff4d6; color: #7a5100; }
.word-card .status.verified { background: #e5f7ef; color: var(--success); }
.icon-btn { padding: 8px 10px; border-radius: 10px; background: #eee8f6; color: var(--primary); }
.game-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.game-picker button { min-height: 70px; }
.game-area { min-height: 300px; text-align: center; display: grid; align-content: center; }
.game-question { font-size: clamp(2rem, 6vw, 4rem); margin: 8px 0 24px; color: var(--primary); }
.answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 700px; margin: 0 auto; }
.answers button { background: #eee8f6; color: var(--text); }
.answers button.correct { background: #dff5eb; color: var(--success); }
.answers button.wrong { background: #fde7e5; color: var(--danger); }
.game-top { display: flex; justify-content: center; gap: 26px; font-weight: 800; }
.memory-board { display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); gap: 10px; }
.memory-card { min-height: 95px; font-size: 1.1rem; background: var(--primary); }
.memory-card.flipped, .memory-card.matched { background: white; color: var(--primary); border: 2px solid var(--primary); }
#leaderboard table { width: 100%; border-collapse: collapse; }
#leaderboard th, #leaderboard td { padding: 9px; border-bottom: 1px solid var(--line); text-align: left; }
.conversation-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.conversation-controls label, dialog label { display: grid; gap: 7px; font-weight: 700; }
.conversation-card { text-align: center; min-height: 270px; display: grid; place-content: center; }
.conversation-card .koich { color: var(--primary); font-size: clamp(2.5rem, 7vw, 5rem); font-weight: 900; margin: 0; }
.conversation-card .meaning { font-size: 1.2rem; color: var(--muted); }
.speech-result { text-align: center; min-height: 26px; font-weight: 700; }
.command-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
code { background: #f1edf6; border-radius: 9px; padding: 7px 9px; color: var(--primary); }
.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); width: min(720px, calc(100% - 24px)); background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 16px 45px rgba(36,19,54,.22); padding: 8px; backdrop-filter: blur(16px); }
.bottom-nav button { background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px; font-size: 1.15rem; }
.bottom-nav button span { font-size: .72rem; }
.bottom-nav button.active { background: #eee8f6; color: var(--primary); }
dialog { border: 0; border-radius: 22px; width: min(520px, calc(100% - 24px)); padding: 0; box-shadow: 0 24px 80px rgba(20,10,30,.35); }
dialog::backdrop { background: rgba(20,10,30,.55); }
dialog form { display: grid; gap: 12px; padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h3 { margin: 0; }
.small { font-size: .82rem; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 34px; }
@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .voice-main { padding: 10px; font-size: .82rem; }
  .hero { grid-template-columns: 1fr; }
  .hero-icon { order: -1; }
  .stats-grid { grid-template-columns: 1fr 1fr 1fr; }
  .search-card, .conversation-controls { grid-template-columns: 1fr; }
  .game-picker { grid-template-columns: 1fr 1fr; }
  .answers { grid-template-columns: 1fr; }
  .memory-board { grid-template-columns: repeat(3, 1fr); }
}
