:root {
  --bg: #fef6e4;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --brand: #7c3aed;
  --right: #22c55e;
  --wrong: #ef4444;
  --shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  --c: var(--brand);
  font-family: 'Baloo 2', 'Noto Sans Hebrew', 'Noto Sans Ethiopic', 'Nyala', 'Ebrima', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1b2e; --card: #2d2a42; --ink: #f3f4f6; --muted: #a1a1aa;
    --shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
[lang="am"], .native { font-family: 'Noto Sans Ethiopic', 'Noto Sans Hebrew', 'Baloo 2', 'Nyala', 'Ebrima', sans-serif; }
[lang="he"] { font-family: 'Noto Sans Hebrew', 'Baloo 2', sans-serif; }

#app { max-width: 960px; margin: 0 auto; padding: 0 16px 40px; }

.bar {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0;
}
.bar h1 { font-size: clamp(1.2rem, 4vw, 1.8rem); margin: 0; text-align: center; line-height: 1.2; }
.icon { font-size: 1.8rem; width: 52px; height: 52px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.stars { background: var(--card); border-radius: 999px; padding: 6px 14px; font-weight: 700; box-shadow: var(--shadow); white-space: nowrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border-radius: 24px; padding: 18px 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  border: 3px solid transparent; transition: transform .1s;
}
button.card:active, .word-btn:active, .letter:active, .opt:active { transform: translateY(3px) scale(.98); }
.card b { font-size: 1.2rem; }
.card small { color: var(--muted); }
.big { font-size: 3.2rem; line-height: 1.1; }
.add { border: 3px dashed var(--muted); background: transparent; box-shadow: none; }

.langs { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.lang { border-color: var(--c); padding: 28px 12px; }
.lang .native { font-size: 2.6rem; color: var(--c); font-weight: 700; }

.menu .card { border-color: var(--c); }
.big-btn b { font-size: 1.3rem; }

.hint { color: var(--muted); text-align: center; margin: 4px 0 14px; }
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; }
.letter {
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; border-bottom: 4px solid var(--c);
}
.letter span { font-size: 2.6rem; line-height: 1.2; font-weight: 700; color: var(--c); }
.letter small { color: var(--muted); font-size: .85rem; }
.letter.small span { font-size: 2rem; }

.detail { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.giant {
  font-size: clamp(6rem, 30vw, 10rem); line-height: 1.1; font-weight: 700; color: var(--c);
  background: var(--card); border-radius: 32px; box-shadow: var(--shadow); min-width: 60%; padding: 10px 30px;
}
.detail h2 { margin: 8px 0 0; font-size: 2rem; }
.sound { margin: 0; font-size: 1.2rem; }
.example { background: var(--card); border-radius: 24px; box-shadow: var(--shadow); padding: 12px 24px; display: flex; flex-direction: column; align-items: center; margin-top: 8px; }
.example .emoji { font-size: 3rem; }
.example .native { font-size: 2rem; font-weight: 700; }
.example small { color: var(--muted); }
.family { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; width: 100%; max-width: 640px; }
.pager { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.pager button, .primary {
  background: var(--c); color: #fff; font-weight: 700; font-size: 1.2rem; padding: 12px 24px; border-radius: 999px; box-shadow: var(--shadow);
}
.primary { background: var(--brand); }

.toolbar { display: flex; justify-content: center; margin-bottom: 12px; font-size: 1.05rem; }
.toolbar input { width: 22px; height: 22px; vertical-align: middle; }
.words { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.word { border-bottom: 4px solid var(--c); }
.word-btn { display: flex; flex-direction: column; align-items: center; width: 100%; gap: 2px; }
.word-btn .emoji { font-size: 3.4rem; line-height: 1.1; }
.word-btn .native { font-size: 1.8rem; font-weight: 700; color: var(--c); line-height: 1.3; }
.word-btn small { color: var(--muted); }

.rec { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 6px; }
.rec-btn { background: #fee2e2; color: #991b1b; border-radius: 999px; padding: 4px 12px; font-size: .95rem; font-weight: 700; }
.rec-btn.recording { background: var(--wrong); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.link { text-decoration: underline; color: var(--brand); font-size: 1rem; }
.danger { color: var(--wrong); font-size: .85rem; }
.foot { text-align: center; margin-top: 28px; }

.progress { height: 12px; background: var(--card); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.progress div { height: 100%; background: var(--c, var(--brand)); background: var(--brand); transition: width .3s; }
.game { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ask { font-size: 1.4rem; margin: 0; font-weight: 700; }
.prompt {
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 16px 32px; min-width: 60%;
  display: flex; flex-direction: column; align-items: center; border: 4px solid var(--c);
}
.prompt .native { font-size: clamp(2rem, 9vw, 3.4rem); font-weight: 700; color: var(--c); }
.prompt small { color: var(--muted); font-size: 1.1rem; }
.speaker { font-size: 4.5rem; padding: 10px 40px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 520px; }
.opt {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow); aspect-ratio: 1.3;
  font-size: clamp(3rem, 14vw, 5rem); border: 4px solid transparent;
}
.letter-opt { font-weight: 700; color: var(--c); }
.opt.right { border-color: var(--right); background: #dcfce7; animation: pop .4s; }
.opt.wrong { border-color: var(--wrong); opacity: .45; animation: shake .3s; }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.form { display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin: 0 auto; font-size: 1.15rem; }
.form input[type=text], .form input:not([type]) {
  display: block; width: 100%; font: inherit; padding: 12px 16px; border-radius: 16px; border: 3px solid var(--brand);
  background: var(--card); color: var(--ink); margin-top: 6px;
}
.form h3 { margin: 10px 0 0; }
.form ul { margin: 0; padding-left: 20px; }
.switch input { width: 24px; height: 24px; vertical-align: middle; margin-right: 8px; }
.avatars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.avatar { font-size: 2.4rem; background: var(--card); border-radius: 18px; padding: 8px 0; box-shadow: var(--shadow); border: 3px solid transparent; }
.avatar.sel { border-color: var(--brand); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 12px 20px; border-radius: 16px; z-index: 50; max-width: calc(100% - 32px); text-align: center; font-size: 1.05rem;
}
.confetti { position: fixed; top: -40px; font-size: 2rem; z-index: 40; pointer-events: none; animation: fall 2.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
