/* Suku Kata – Kasih4u Early Reading App (Malay & English). Fredoka/Nunito sky+paper design. */
@font-face { font-family: "Fredoka"; src: url("/assets/fonts/fredoka-latin.woff2") format("woff2"); font-weight: 500 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/assets/fonts/nunito-latin.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
:root {
  --paper: #fff7ec; --sky: #bfe9ff; --card: #fff; --ink: #1f2347; --muted: #4a4f78;
  --blue: #2354d6; --red: #d92d4b; --green: #15803d; --purple: #7c3aed; --yellow: #ffb703;
  --line: rgba(31,35,71,.14); --line-strong: rgba(31,35,71,.28);
  --f-d: "Fredoka", ui-rounded, system-ui, sans-serif;
  --f-b: "Nunito", ui-rounded, system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; font-family: var(--f-b); color: var(--ink); background: linear-gradient(180deg, var(--sky) 0, #e8f7ff 320px, var(--paper) 620px); }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

.top { display: flex; align-items: center; gap: 10px; max-width: 920px; margin: 0 auto; padding: calc(10px + var(--safe-t)) 16px 8px; }
.brand { font-family: var(--f-d); font-weight: 700; font-size: 1.55rem; letter-spacing: -.02em; }
.brand b { color: var(--red); }
.spacer { flex: 1; }
.stars-pill { display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--ink); background: #fff3c9; font-family: var(--f-d); font-weight: 700; }
.icon-btn { display: inline-grid; place-items: center; min-width: 46px; height: 46px; padding: 0 12px; border-radius: 999px; border: 2px solid var(--ink); background: #fff; font-family: var(--f-d); font-weight: 700; text-decoration: none; box-shadow: 0 3px 0 var(--ink); }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.wrap { max-width: 920px; margin: 0 auto; padding: 6px 14px calc(36px + var(--safe-b)); display: grid; gap: 14px; }

/* Mode Tabs */
.tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.tab { display: grid; justify-items: center; gap: 2px; padding: 10px 4px; border-radius: 20px; border: 2.5px solid var(--ink); background: #fff; font-family: var(--f-d); font-weight: 700; font-size: .95rem; box-shadow: 0 4px 0 var(--ink); transition: transform 120ms ease; }
.tab span { font-size: 1.5rem; line-height: 1.1; }
.tab.on { background: var(--yellow); }
.tab:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }

/* Stage Panel */
.panel { background: #fff; border: 3px solid var(--ink); border-radius: 28px; padding: 18px 16px 22px; box-shadow: 0 6px 0 var(--ink); display: grid; gap: 16px; justify-items: center; text-align: center; }
.sub-help { margin: 0; color: var(--muted); font-weight: 800; font-size: 1rem; }

/* Color-coded syllables (Classic Malaysian reading book style!) */
.sy0 { color: var(--red); }
.sy1 { color: var(--blue); }
.sy2 { color: var(--green); }
.sy3 { color: var(--purple); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 10px 24px; border-radius: 999px; border: 2.5px solid var(--ink); background: #fff; font-family: var(--f-d); font-weight: 700; font-size: 1.1rem; box-shadow: 0 3px 0 var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn-primary { background: var(--yellow); }
.btn-mint { background: #cdf0df; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.chip { min-width: 44px; min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--ink); background: #fff; font-family: var(--f-d); font-weight: 700; font-size: 1.05rem; }
.chip.on { background: var(--ink); color: #fff; }

/* Chart Mode */
.vowel-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.v-tile { min-width: 56px; height: 56px; border-radius: 18px; border: 2.5px solid var(--ink); background: #fff0b8; font-family: var(--f-d); font-weight: 700; font-size: 1.7rem; box-shadow: 0 3px 0 var(--ink); }
.v-tile:active, .v-tile.glow { transform: scale(1.08); background: var(--yellow); }

.kv-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 560px; }
.kv-tile { min-height: 82px; border-radius: 22px; border: 3px solid var(--ink); font-family: var(--f-d); font-weight: 700; font-size: clamp(1.7rem, 6vw, 2.5rem); box-shadow: 0 5px 0 var(--ink); transition: transform 140ms ease; }
.kv-tile:nth-child(1) { background: #ffd9de; color: var(--red); }
.kv-tile:nth-child(2) { background: #d9e2ff; color: var(--blue); }
.kv-tile:nth-child(3) { background: #d6f3e6; color: var(--green); }
.kv-tile:nth-child(4) { background: #ead9ff; color: var(--purple); }
.kv-tile:nth-child(5) { background: #ffe1cc; color: #c2410c; }
.kv-tile:active, .kv-tile.glow { transform: translateY(-4px) scale(1.06); box-shadow: 0 8px 0 var(--ink); }

.example-card { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-radius: 22px; border: 3px dashed var(--ink); background: #fffaf0; font-family: var(--f-d); font-size: 1.9rem; font-weight: 700; min-height: 76px; }
.example-card .ico { font-size: 2.6rem; line-height: 1; }
.example-card .dot { color: var(--muted); opacity: .5; margin: 0 2px; }

/* Blend Mode */
.pic-big { font-size: clamp(4.6rem, 16vw, 6.5rem); line-height: 1.05; cursor: pointer; transition: transform 150ms ease; }
.pic-big:active { transform: scale(1.1); }
.slots { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.slot { min-width: 78px; min-height: 72px; padding: 8px 16px; border-radius: 20px; border: 3px dashed var(--line-strong); background: #f8f9ff; font-family: var(--f-d); font-weight: 700; font-size: 2.1rem; display: grid; place-items: center; }
.slot.filled { border-style: solid; border-color: var(--ink); background: #fff; box-shadow: 0 4px 0 var(--ink); animation: pop 280ms ease; }
.slot.win { background: #cdf0df; }

.tray { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.syl-btn { min-width: 82px; min-height: 68px; padding: 8px 18px; border-radius: 20px; border: 3px solid var(--ink); background: #fff3c9; font-family: var(--f-d); font-weight: 700; font-size: 1.9rem; box-shadow: 0 4px 0 var(--ink); }
.syl-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.syl-btn.used { opacity: .25; pointer-events: none; }
.syl-btn.wrong { background: #fde8e6; animation: shake 320ms; }

/* Quiz Mode */
.quiz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 520px; }
.quiz-opt { display: grid; justify-items: center; gap: 6px; min-height: 118px; padding: 14px 10px; border-radius: 24px; border: 3px solid var(--ink); background: #fff; font-family: var(--f-d); font-weight: 700; font-size: 1.85rem; box-shadow: 0 5px 0 var(--ink); }
.quiz-opt .qi { font-size: 2.6rem; line-height: 1; }
.quiz-opt:nth-child(1) { background: #ffe9ec; }
.quiz-opt:nth-child(2) { background: #fff3c9; }
.quiz-opt:nth-child(3) { background: #e3f6ec; }
.quiz-opt:nth-child(4) { background: #e8edff; }
.quiz-opt:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.quiz-opt.ok { background: #cdf0df !important; border-color: var(--green); }
.quiz-opt.wrong { background: #fde8e6 !important; animation: shake 320ms; }

/* Sentence Reader Mode */
.story-pic { font-size: 5.5rem; line-height: 1.05; }
.sentence { display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center; padding: 8px 4px; }
.word-pill { padding: 8px 16px; border-radius: 20px; border: 2.5px solid var(--line-strong); background: #fffaf0; font-family: var(--f-d); font-weight: 700; font-size: clamp(1.75rem, 6vw, 2.4rem); transition: transform 120ms ease, background 120ms ease; }
.word-pill:active, .word-pill.glow { transform: scale(1.08); background: #fff0b8; border-color: var(--ink); }
.story-nav { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.counter { font-family: var(--f-d); font-weight: 700; color: var(--muted); }

/* 📚 Digital Storybooks Shelf & Interactive Page Reader */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; width: 100%; }
.book-card { position: relative; display: grid; justify-items: center; align-content: space-between; gap: 8px; min-height: 174px; padding: 16px 12px 14px; border-radius: 22px; border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); text-align: center; transition: transform 120ms ease; }
.book-card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.book-card .bk-ico { font-size: 3.1rem; line-height: 1.05; }
.book-card .bk-title { font-family: var(--f-d); font-weight: 700; font-size: 1.02rem; line-height: 1.2; color: var(--ink); }
.book-card .bk-meta { font-size: .8rem; font-weight: 800; color: var(--muted); }
.book-card .bk-done { position: absolute; top: 8px; right: 8px; padding: 2px 8px; border-radius: 999px; background: #16a34a; color: #fff; font-size: .72rem; font-weight: 800; }

.book-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
.book-top h2 { margin: 0; font-family: var(--f-d); font-size: 1.15rem; flex: 1; text-align: center; }
.book-stage { width: 100%; padding: 22px 14px; border-radius: 26px; border: 3px solid var(--ink); display: grid; gap: 14px; justify-items: center; }
.book-art { font-size: clamp(3.2rem, 11vw, 4.6rem); letter-spacing: 6px; line-height: 1.15; filter: drop-shadow(0 4px 0 rgba(31,35,71,.12)); }
.book-text { display: flex; flex-wrap: wrap; gap: 8px 10px; justify-content: center; }
.book-text .word-pill { font-size: clamp(1.35rem, 4.8vw, 1.85rem); padding: 6px 12px; background: rgba(255,255,255,.92); }
.page-dots { display: flex; gap: 8px; justify-content: center; }
.page-dot { width: 12px; height: 12px; border-radius: 999px; border: 2px solid var(--ink); background: #fff; }
.page-dot.on { width: 28px; background: var(--yellow); }

@keyframes pop { from { transform: scale(.78); } to { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@media (max-width: 480px) {
  .tab { font-size: .74rem; padding: 7px 2px; border-radius: 16px; }
  .tab span { font-size: 1.25rem; }
  .kv-row { gap: 6px; }
  .kv-tile { min-height: 68px; border-radius: 16px; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
