/* Letter Friends — styles */
@font-face { font-family: 'Andika'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/andika-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Andika'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/andika-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/nunito-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/nunito-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 800; font-display: swap; src: url('fonts/nunito-latin-800-normal.woff2') format('woff2'); }

:root {
  --bg: #FFF7EA; --bg2: #FFEFD6; --card: #FFFFFF; --ink: #2B2D42; --muted: #6B7280; --line: #EEE3D2;
  --coral: #FF7A59; --coral-d: #D95A3B; --teal: #2EC4B6; --teal-d: #1E9E92; --yellow: #FFD166; --yellow-d: #D9AC3E;
  --purple: #7B5EA7; --purple-d: #5E4485; --blue: #3A86FF; --blue-d: #2A64C4; --green: #43AA8B; --green-d: #2F8A6E;
  --pink: #E76F9B; --red: #EF476F; --gray: #CBD5E1;
  --radius: 26px; --shadow: 0 10px 30px rgba(43,45,66,.10);
  --font-ui: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-letters: 'Andika', 'Chalkboard SE', 'Comic Sans MS', 'Nunito', sans-serif;
  --topbar: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(circle at 10% 10%, #FFE7C9 0, transparent 40%), radial-gradient(circle at 90% 90%, #E0F7F4 0, transparent 40%);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  overflow: hidden; display: flex; flex-direction: column; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }
.letters { font-family: var(--font-letters); }

/* ---- top bar ---- */
.topbar { height: var(--topbar); display: flex; align-items: center; gap: 10px; padding: 0 14px; flex: 0 0 auto; }
.topbar .spacer { flex: 1; }
.iconbtn { width: 52px; height: 52px; border-radius: 18px; border: 0; background: var(--card); box-shadow: 0 4px 0 var(--line); font-size: 26px; display: grid; place-items: center; cursor: pointer; }
.iconbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.pill { background: var(--card); border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 20px; box-shadow: 0 4px 0 var(--line); display: flex; align-items: center; gap: 6px; }
.act-title { font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dots { display: flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: block; }
.dots i.done { background: var(--teal); }
.dots i.now { background: var(--coral); transform: scale(1.3); }

/* ---- screens ---- */
#stage { flex: 1; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 18px 28px; }
.screen.center { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }

/* ---- buttons ---- */
.btn {
  border: 0; cursor: pointer; border-radius: 999px; padding: 16px 30px; font-weight: 800; font-size: 24px;
  background: var(--coral); color: #fff; box-shadow: 0 7px 0 var(--coral-d); transition: transform .05s; display: inline-flex; align-items: center; gap: 10px; justify-content: center; line-height: 1.1;
}
.btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--coral-d); }
.btn.big { font-size: 30px; padding: 22px 40px; }
.btn.small { font-size: 18px; padding: 10px 18px; box-shadow: 0 5px 0 var(--coral-d); }
.btn.teal { background: var(--teal); box-shadow: 0 7px 0 var(--teal-d); } .btn.teal:active { box-shadow: 0 2px 0 var(--teal-d); }
.btn.yellow { background: var(--yellow); color: var(--ink); box-shadow: 0 7px 0 var(--yellow-d); } .btn.yellow:active { box-shadow: 0 2px 0 var(--yellow-d); }
.btn.purple { background: var(--purple); box-shadow: 0 7px 0 var(--purple-d); } .btn.purple:active { box-shadow: 0 2px 0 var(--purple-d); }
.btn.green { background: var(--green); box-shadow: 0 7px 0 var(--green-d); } .btn.green:active { box-shadow: 0 2px 0 var(--green-d); }
.btn.blue { background: var(--blue); box-shadow: 0 7px 0 var(--blue-d); } .btn.blue:active { box-shadow: 0 2px 0 var(--blue-d); }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: 0 5px 0 var(--line); } .btn.ghost:active { box-shadow: 0 1px 0 var(--line); }
.btn:disabled, .btn.locked { opacity: .45; filter: grayscale(.6); pointer-events: none; }
.btnrow { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }

/* ---- home ---- */
.hero { display: flex; align-items: center; gap: 18px; width: min(100%, 900px); margin: 6px auto 12px; }
.hero .owl { width: 96px; height: 96px; flex: 0 0 auto; }
.hero h1 { margin: 0; font-size: 30px; }
.hero p { margin: 4px 0 0; color: var(--muted); font-size: 18px; font-weight: 700; }
.home-actions { width: min(100%, 900px); margin: 0 auto 16px; display: grid; grid-template-columns: 1fr; gap: 12px; }
.home-actions .btn.big { width: 100%; }
.home-actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.island { width: min(100%, 900px); margin: 0 auto 14px; background: var(--card); border-radius: var(--radius); padding: 14px 16px 16px; box-shadow: var(--shadow); border-left: 12px solid var(--gc, var(--coral)); }
.island h3 { margin: 0 0 10px; font-size: 18px; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.island h3 b { color: var(--ink); font-size: 20px; }
.bubbles { display: flex; flex-wrap: wrap; gap: 10px; }
.bubble {
  width: 64px; height: 64px; border-radius: 50%; border: 0; font-family: var(--font-letters); font-weight: 700; font-size: 30px; cursor: pointer;
  background: var(--gc, var(--coral)); color: #fff; box-shadow: 0 5px 0 rgba(0,0,0,.18); display: grid; place-items: center; line-height: 1;
}
.bubble:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.bubble.locked { background: #E9E4DA; color: #B8B0A3; box-shadow: 0 5px 0 #D8D1C5; }
.bubble.now { outline: 5px solid var(--yellow); outline-offset: 3px; animation: pulse 1.6s infinite; }
.bubble.multi { font-size: 22px; }
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.08);} }

/* ---- activity layout ---- */
.act { width: min(100%, 980px); margin: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; }
#activity.screen.center { justify-content: flex-start; }
.prompt { font-size: 22px; font-weight: 800; text-align: center; margin: 4px 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.prompt .kw { font-size: 42px; }
.tiles { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; align-items: center; }
.tile {
  width: clamp(88px, 18vw, 180px); height: clamp(88px, 18vw, 180px); border-radius: 26px; border: 4px solid var(--line); background: var(--card);
  font-family: var(--font-letters); font-weight: 700; font-size: clamp(48px, 10vw, 104px); display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 8px 0 var(--line); line-height: 1; color: var(--ink); position: relative; transition: transform .08s;
}
.tile.multi { font-size: clamp(34px, 6.5vw, 64px); }
.tile.long { width: clamp(120px, 24vw, 210px); font-size: clamp(30px, 5.5vw, 56px); }
.tile:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--line); }
.tile.correct { background: var(--green); border-color: var(--green-d); color: #fff; box-shadow: 0 8px 0 var(--green-d); animation: pop .4s; }
.tile.wrong { background: #F1F1F1; color: #9CA3AF; animation: shake .45s; }
.tile.hint { animation: bounce .8s infinite; border-color: var(--yellow); box-shadow: 0 8px 0 var(--yellow-d); }
.tile.selected { border-color: var(--blue); box-shadow: 0 8px 0 var(--blue-d); transform: translateY(-4px); }
.tile.matched { background: var(--teal); border-color: var(--teal-d); color: #fff; box-shadow: 0 8px 0 var(--teal-d); pointer-events: none; }
.tile.picture { font-size: clamp(56px, 11vw, 100px); font-family: var(--font-ui); }
.tile.small { width: clamp(70px, 12vw, 100px); height: clamp(70px, 12vw, 100px); font-size: clamp(36px, 6vw, 56px); border-radius: 20px; }
.tile.small.multi { font-size: clamp(24px, 4.2vw, 40px); }
.tile.ghost { background: #FBF7F0; border-style: dashed; color: transparent; box-shadow: none; }
.tile.tray { box-shadow: 0 6px 0 var(--line); }
.tile.disabled { opacity: .35; pointer-events: none; }
.tile.flash { animation: flashred .6s; }
.tile.done { pointer-events: none; }
@keyframes pop { 0% { transform: scale(1);} 40% { transform: scale(1.15);} 100% { transform: scale(1);} }
@keyframes shake { 0%,100% { transform: translateX(0);} 20% { transform: translateX(-10px);} 40% { transform: translateX(10px);} 60% { transform: translateX(-8px);} 80% { transform: translateX(8px);} }
@keyframes bounce { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-12px);} }
@keyframes flashred { 0%,100% { background: var(--card);} 50% { background: #FFD1DC; border-color: var(--red);} }

/* sound buttons under graphemes */
.word-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; align-items: flex-end; }
.gtile { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.gtile .tile.lit { background: #FFF3C4; border-color: var(--yellow); box-shadow: 0 8px 0 var(--yellow-d); }
.sbtn { height: 14px; display: flex; align-items: center; }
.sbtn.dot { width: 14px; border-radius: 50%; background: var(--ink); }
.sbtn.bar { width: 100%; height: 8px; border-radius: 4px; background: var(--ink); margin-top: 3px; }
.slot-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.tray-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; padding: 14px; background: var(--bg2); border-radius: var(--radius); }
.bigpic { font-size: clamp(90px, 18vw, 160px); line-height: 1.1; text-align: center; }
.bigpic.hidden-pic { filter: blur(14px); opacity: .5; }
.wordbig { font-family: var(--font-letters); font-weight: 700; font-size: clamp(56px, 10vw, 96px); line-height: 1.1; }

/* meet the letter */
.meet { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: min(100%, 860px); align-items: stretch; }
.meet .card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; min-height: 240px; }
.meet .biglet { font-family: var(--font-letters); font-weight: 700; font-size: clamp(120px, 22vw, 220px); line-height: 1; color: var(--coral); }
.meet .biglet.multi { font-size: clamp(90px, 16vw, 170px); }
.meet .cap { font-family: var(--font-letters); font-weight: 700; font-size: 34px; color: var(--muted); }
.meet .kwpic { font-size: clamp(90px, 16vw, 150px); line-height: 1.1; }
.meet .kwword { font-family: var(--font-letters); font-weight: 700; font-size: 40px; }
.meet .kwword b { color: var(--coral); }
.badge { display: inline-flex; align-items: center; gap: 8px; background: var(--bg2); border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 18px; }
.examples { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.chip { background: var(--card); border-radius: 20px; padding: 10px 16px; box-shadow: 0 5px 0 var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; min-width: 110px; }
.chip:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.chip .e { font-size: 44px; line-height: 1.1; }
.chip .w { font-family: var(--font-letters); font-weight: 700; font-size: 24px; }
.chip .w b { color: var(--coral); }
.tip { color: var(--muted); font-weight: 700; font-size: 16px; text-align: center; max-width: 700px; }

/* sentence reading */
.sentence { display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center; align-items: center; max-width: 900px; }
.word { font-family: var(--font-letters); font-weight: 700; font-size: clamp(34px, 6vw, 60px); padding: 6px 14px; border-radius: 18px; background: var(--card); box-shadow: 0 5px 0 var(--line); cursor: pointer; line-height: 1.1; }
.word:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.word.tricky { color: var(--purple); text-decoration: underline dotted; text-underline-offset: 6px; }
.word.lit { background: #FFF3C4; box-shadow: 0 5px 0 var(--yellow-d); }
.word.punct { background: transparent; box-shadow: none; padding: 0; cursor: default; }
.book { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; width: min(100%, 900px); display: flex; flex-direction: column; align-items: center; gap: 18px; min-height: 380px; justify-content: center; }
.book .scene { font-size: clamp(90px, 18vw, 170px); line-height: 1.1; }
.book .pageno { color: var(--muted); font-weight: 700; }
.book .title { font-size: 40px; font-weight: 800; }

/* trace */
.trace-wrap { position: relative; width: min(100%, 520px); aspect-ratio: 1; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.trace-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

/* flash card */
.flash { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); width: min(100%, 520px); min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; cursor: pointer; padding: 20px; }
.flash .biglet { font-family: var(--font-letters); font-weight: 700; font-size: clamp(120px, 22vw, 200px); line-height: 1; }
.flash .reveal { display: flex; align-items: center; gap: 14px; font-family: var(--font-letters); font-weight: 700; font-size: 34px; min-height: 70px; }
.flash .reveal .e { font-size: 60px; }
.flash .trickyword { font-family: var(--font-letters); font-weight: 700; font-size: clamp(80px, 14vw, 150px); color: var(--purple); }

/* stickers */
.stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px; width: min(100%, 900px); }
.sticker { aspect-ratio: 1; background: var(--card); border-radius: 22px; box-shadow: var(--shadow); display: grid; place-items: center; font-size: 54px; }
.sticker.empty { color: #D9D2C6; font-size: 40px; }

/* reward */
.reward { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.reward .stars { font-size: 64px; letter-spacing: 6px; }
.reward .newsticker { font-size: 140px; line-height: 1.1; animation: pop .8s; }
.reward h2 { margin: 0; font-size: 40px; }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(43,45,66,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: var(--radius); padding: 24px; width: min(100%, 560px); max-height: 90dvh; overflow: auto; box-shadow: var(--shadow); text-align: center; }
.modal h2 { margin: 0 0 8px; }
.modal p { font-size: 18px; color: var(--muted); font-weight: 700; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 800; z-index: 70; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }
.star-fly { position: fixed; font-size: 40px; pointer-events: none; z-index: 65; animation: fly 1s forwards; }
@keyframes fly { 0% { transform: translate(0,0) scale(1); opacity: 1;} 100% { transform: translate(var(--dx), var(--dy)) scale(.4); opacity: 0;} }

/* ---- grown-ups panel ---- */
.grown { width: min(100%, 900px); margin: 0 auto; -webkit-user-select: text; user-select: text; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 0; background: var(--card); border-radius: 999px; padding: 10px 18px; font-weight: 800; font-size: 16px; box-shadow: 0 4px 0 var(--line); cursor: pointer; }
.tabs button.on { background: var(--ink); color: #fff; box-shadow: 0 4px 0 #000; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 14px; font-size: 16px; line-height: 1.5; }
.panel h2 { margin: 0 0 10px; font-size: 22px; }
.panel h3 { margin: 18px 0 6px; font-size: 18px; }
.panel p { margin: 6px 0; }
.panel table { border-collapse: collapse; width: 100%; font-size: 15px; }
.panel th, .panel td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.panel th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.field label { font-weight: 800; }
.field small { display: block; color: var(--muted); font-weight: 600; }
.field input[type=text], .field select, .field input[type=number] { font: inherit; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); min-width: 180px; }
.field input[type=range] { width: 200px; }
.switch { width: 58px; height: 34px; border-radius: 999px; background: #D9D2C6; border: 0; position: relative; cursor: pointer; flex: 0 0 auto; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--green); } .switch.on::after { left: 28px; }
.progress-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.pg { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-family: var(--font-letters); font-weight: 700; font-size: 22px; background: var(--bg2); color: var(--muted); }
.pg.learned { background: var(--teal); color: #fff; }
.pg.weak { background: var(--coral); color: #fff; }
.pg.now { outline: 3px solid var(--yellow); }
textarea.backup { width: 100%; min-height: 90px; font: 13px monospace; border-radius: 12px; border: 2px solid var(--line); padding: 8px; }
.btn-plain { border: 0; background: var(--bg2); border-radius: 12px; padding: 10px 16px; font-weight: 800; cursor: pointer; font-size: 15px; }
.btn-plain.danger { background: #FFE1E8; color: var(--red); }

@media (max-width: 640px) {
  .meet { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
  .btn.big { font-size: 24px; padding: 18px 26px; }
  .topbar { padding: 0 8px; gap: 6px; }
  .act-title { font-size: 16px; }
}
@media (max-height: 600px) {
  .meet .card { min-height: 180px; }
  .meet .biglet { font-size: 120px; }
}
