/* Little Letters styles */
@font-face { font-family: 'Andika'; src: url(fonts/andika-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Andika'; src: url(fonts/andika-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Noto Sans Georgian'; src: url(fonts/noto-sans-georgian-georgian-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Noto Sans Georgian'; src: url(fonts/noto-sans-georgian-georgian-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #fff7ed; --paper: #ffffff; --ink: #2e2140; --muted: #6b5b7b; --line: #eadfd3;
  --learn: #f97316; --learn-soft: #ffedd5; --build: #0d9488; --build-soft: #ccfbf1;
  --trace: #7c3aed; --trace-soft: #ede9fe; --sun: #facc15; --good: #16a34a; --oops: #ea580c;
  --radius: 22px; --shadow: 0 4px 0 rgba(46, 33, 64, .12);
  --top: 60px; --tab: 64px;
  --font: 'Andika', 'Noto Sans Georgian', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 18px; line-height: 1.45;
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
:lang(ka) body, body:lang(ka) { line-height: 1.55; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a { touch-action: manipulation; }
a { color: #6d28d9; }
:focus-visible { outline: 4px solid #2563eb; outline-offset: 3px; border-radius: 8px; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 100; }
.skip:focus { top: 8px; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 8px;
  padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  background: rgba(255, 247, 237, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 2px solid var(--line);
}
.icon-btn { min-width: 48px; height: 48px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper); display: inline-grid; place-items: center; padding: 0 10px; }
.burger { display: grid; gap: 5px; width: 24px; }
.burger span { display: block; height: 3px; border-radius: 3px; background: var(--ink); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 700; min-width: 0; flex: 1; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--learn); color: #fff; font-size: 17px; flex: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 18px; }
.lang-switch { display: flex; background: var(--paper); border: 2px solid var(--line); border-radius: 14px; padding: 3px; flex: none; }
.lang-switch button { border: 0; background: none; min-height: 40px; padding: 0 10px; border-radius: 10px; font-size: 15px; font-weight: 700; color: var(--muted); }
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
@media (max-width: 400px) { .brand-name { display: none; } }
@media (max-width: 340px) { .lang-switch button { padding: 0 8px; font-size: 14px; } }

/* Drawer */
.overlay { position: fixed; inset: 0; background: rgba(46, 33, 64, .45); z-index: 40; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); z-index: 50; background: var(--paper);
  padding: 14px max(14px, env(safe-area-inset-left)); box-shadow: 8px 0 30px rgba(0, 0, 0, .18);
  transform: translateX(-105%); transition: transform .22s ease; overflow-y: auto;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.drawer-title { font-weight: 700; color: var(--muted); }
.drawer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.drawer a { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; border-radius: 16px; background: var(--bg); color: var(--ink); text-decoration: none; font-weight: 700; font-size: 20px; }
.drawer a[aria-current="page"] { background: var(--learn-soft); box-shadow: inset 4px 0 0 var(--learn); }

/* Main + tab bar */
main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(var(--tab) + 28px + env(safe-area-inset-bottom)); outline: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper); border-top: 2px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 700; }
.tabbar .ti { font-size: 24px; line-height: 1; }
.tabbar a[aria-current="page"] { color: var(--ink); background: var(--bg); box-shadow: inset 0 4px 0 var(--learn); }
.tabbar a[data-route="build"][aria-current="page"] { box-shadow: inset 0 4px 0 var(--build); }
.tabbar a[data-route="trace"][aria-current="page"] { box-shadow: inset 0 4px 0 var(--trace); }

h1 { font-size: 28px; line-height: 1.2; margin: 4px 0 12px; outline: none; }
h2 { font-size: 21px; margin: 22px 0 10px; }
.lead { color: var(--muted); margin: 0 0 18px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 18px;
  border-radius: 18px; border: 2px solid var(--ink); background: var(--paper); font-weight: 700; font-size: 18px;
  box-shadow: var(--shadow); text-decoration: none; color: var(--ink); touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn .bi { font-size: 22px; line-height: 1; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-learn { background: var(--learn); border-color: #c2410c; color: #fff; }
.btn-build { background: var(--build); border-color: #115e59; color: #fff; }
.btn-trace { background: var(--trace); border-color: #5b21b6; color: #fff; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > .btn { flex: 1 1 0; min-width: 0; }
.seg { display: flex; gap: 6px; background: var(--paper); border: 2px solid var(--line); border-radius: 18px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 48px; border: 0; border-radius: 14px; background: none; font-weight: 700; color: var(--muted); padding: 0 8px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Home */
.hello { font-size: 30px; }
.cards { display: grid; gap: 14px; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(3, 1fr); } .card { flex-direction: column; text-align: center; } }
.card {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--paper); border: 3px solid var(--c); box-shadow: 0 5px 0 var(--c); min-height: 120px;
}
.card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--c); }
.card-learn { --c: var(--learn); } .card-build { --c: var(--build); } .card-trace { --c: var(--trace); }
.card-art { flex: none; width: 88px; height: 88px; border-radius: 20px; background: var(--soft); display: grid; place-items: center; font-size: 44px; font-weight: 700; }
.card-learn .card-art { --soft: var(--learn-soft); color: var(--learn); }
.card-build .card-art { --soft: var(--build-soft); }
.card-trace .card-art { --soft: var(--trace-soft); color: var(--trace); }
.card-art svg { width: 70px; height: 70px; }
.card-text { display: grid; gap: 2px; }
.card-title { font-size: 22px; font-weight: 700; }
.card-desc { color: var(--muted); font-size: 16px; }
.card-prog { font-size: 15px; font-weight: 700; color: var(--ink); }
.trace-demo { font-size: 54px; color: transparent; -webkit-text-stroke: 2px var(--trace); }
.grownups { margin-top: 26px; text-align: center; color: var(--muted); font-size: 16px; }

/* Learn */
.letter-stage { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 8px; }
.arrow { width: 56px; height: 72px; border-radius: 18px; border: 2px solid var(--line); background: var(--paper); font-size: 28px; font-weight: 700; }
.big-letter {
  text-align: center; font-size: clamp(96px, 34vw, 180px); line-height: 1.15; font-weight: 700; color: var(--learn);
  background: var(--paper); border-radius: 28px; border: 3px solid var(--learn-soft); padding: 4px 0;
}
.example { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0; }
.pic { width: 96px; height: 96px; flex: none; }
.pic svg, .pic-lg svg { width: 100%; height: 100%; display: block; }
.ex-word { font-size: 34px; font-weight: 700; letter-spacing: .02em; overflow-wrap: anywhere; }
.ex-word mark { background: var(--learn-soft); color: var(--learn); border-radius: 8px; padding: 0 2px; }
.cue { text-align: center; color: var(--muted); margin: 10px 0 4px; font-size: 17px; }
.tip { background: var(--paper); border: 2px dashed var(--line); border-radius: 16px; padding: 10px 14px; font-size: 15px; color: var(--muted); margin: 12px 0; }
.alpha-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.alpha-grid button {
  position: relative; min-height: 56px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper);
  font-size: 26px; font-weight: 700; padding: 0; touch-action: manipulation;
}
.alpha-grid button[aria-current="true"] { border-color: var(--c, var(--learn)); background: var(--c-soft, var(--learn-soft)); }
.alpha-grid button.seen::after { content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.quiz-pic { width: min(56vw, 220px); aspect-ratio: 1; margin: 0 auto 8px; }
.quiz-q { text-align: center; font-weight: 700; font-size: 20px; margin: 4px 0 14px; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.choice { min-height: 96px; font-size: 54px; font-weight: 700; border-radius: 22px; border: 3px solid var(--ink); background: var(--paper); box-shadow: var(--shadow); touch-action: manipulation; }
.choice.right { background: #dcfce7; border-color: var(--good); }
.choice.tried { opacity: .4; }
.feedback { min-height: 30px; text-align: center; font-weight: 700; margin: 12px 0; }
.feedback.good { color: var(--good); }

.says .btn { flex-direction: column; gap: 2px; min-height: 68px; padding: 6px 4px; font-size: 16px; }
.says .btn .bi { font-size: 24px; }

/* Build */
.levels { margin-bottom: 12px; }
.build-card { position: relative; background: var(--paper); border-radius: 28px; border: 3px solid var(--build-soft); padding: 14px; overflow: hidden; }
.pic-wrap { position: relative; display: flex; justify-content: center; align-items: center; gap: 12px; }
.pic-lg { width: min(42vw, 170px); aspect-ratio: 1; }
.pic-lg.pop { animation: pop .6s ease; }
.hear { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--build); background: var(--build-soft); font-size: 28px; flex: none; touch-action: manipulation; }
.word-count { text-align: center; color: var(--muted); font-size: 15px; margin: 4px 0 10px; }
.slots, .tray { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.slots { margin: 6px 0 4px; }
.slot {
  width: var(--sz); height: calc(var(--sz) * 1.15); border-radius: 16px; border: 3px dashed #94a3b8; background: #f8fafc;
  padding: 0; display: grid; place-items: center; touch-action: none;
}
.slot.hover, .slot.target { border-color: var(--build); background: var(--build-soft); border-style: solid; }
.slot.filled { border-style: solid; border-color: var(--build); background: #fff; }
.slot.wrong { border-color: var(--oops); background: #fff7ed; }
.slot.solved { border-color: var(--good); background: #dcfce7; }
.tile {
  width: var(--sz); height: calc(var(--sz) * 1.15); border-radius: 16px; border: 3px solid #b45309; background: #fef3c7;
  font-size: calc(var(--sz) * .58); font-weight: 700; display: grid; place-items: center; padding: 0;
  box-shadow: 0 4px 0 #d97706; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.slot .tile { box-shadow: none; border: 0; background: transparent; width: 100%; height: 100%; }
.slot.wrong .tile { color: var(--oops); }
.tile.selected { background: var(--build); color: #fff; border-color: #115e59; box-shadow: 0 4px 0 #115e59; transform: translateY(-4px); }
.tile.lifting { opacity: .25; }
.tile-ghost { position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, -60%) scale(1.12); box-shadow: 0 10px 20px rgba(0, 0, 0, .25); }
.tray { min-height: calc(var(--sz) * 1.15 + 10px); padding: 10px 0 4px; border-top: 2px dashed var(--line); margin-top: 6px; }
.build-msg { min-height: 54px; text-align: center; font-weight: 700; margin: 8px 0 6px; display: grid; place-items: center; }
.build-msg.good { color: var(--good); font-size: 22px; }
.build-msg.oops { color: var(--oops); }
.how { color: var(--muted); font-size: 15px; text-align: center; margin-top: 12px; }
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst span { position: absolute; left: 50%; top: 30%; font-size: 26px; animation: fly 1s ease-out forwards; }
@keyframes fly { from { transform: translate(-50%, 0) scale(.4); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), var(--dy)) scale(1); opacity: 0; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12) rotate(-3deg); } 100% { transform: scale(1); } }

/* Trace */
.trace-top { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 8px; margin-bottom: 10px; }
.trace-label { text-align: center; font-size: 22px; font-weight: 700; color: var(--trace); }
.trace-stage {
  width: 100%; max-width: min(560px, calc(100vh - 330px)); max-width: min(560px, calc(100dvh - 330px)); min-width: 240px;
  aspect-ratio: 1; margin: 0 auto; background: #fff; border-radius: 26px; border: 3px solid var(--trace-soft); overflow: hidden; position: relative;
}
.trace-stage canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.trace-actions { margin-top: 12px; }
.trace-msg { min-height: 30px; text-align: center; font-weight: 700; color: var(--good); margin: 10px 0 0; }

/* About + contact */
.panel { background: var(--paper); border-radius: var(--radius); border: 2px solid var(--line); padding: 16px 18px; margin-bottom: 14px; }
.panel p { margin: 0 0 12px; } .panel p:last-child { margin-bottom: 0; }
.note { font-size: 15px; color: var(--muted); }
.adult { display: flex; gap: 10px; align-items: flex-start; background: #eff6ff; border: 2px solid #bfdbfe; border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; font-weight: 700; }
.form { display: grid; gap: 16px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.field input, .field textarea { width: 100%; border: 2px solid #cbd5e1; border-radius: 14px; padding: 12px 14px; font-size: 18px; background: #fff; min-height: 52px; }
.field textarea { min-height: 150px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: #2563eb; outline: 3px solid #bfdbfe; }
.field [aria-invalid="true"] { border-color: #dc2626; background: #fef2f2; }
.err { color: #b91c1c; font-size: 15px; margin-top: 6px; font-weight: 700; }
.err:empty { display: none; }
.form-status { border-radius: 14px; padding: 12px 14px; font-weight: 700; }
.form-status:empty { display: none; }
.form-status.bad { background: #fef2f2; color: #991b1b; border: 2px solid #fecaca; }
.success { text-align: center; }
.success .big { font-size: 56px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  width: max-content; max-width: calc(100vw - 32px); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 16px;
  font-size: 16px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.noscript { padding: 20px; text-align: center; }

body.menu-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) { body { font-size: 19px; } h1 { font-size: 32px; } }
