/* EG1 Alpha — warm paper, big type, big targets. iPad landscape first. */
:root {
  --paper: #f8ecd8;
  --paper-2: #fdf6e9;
  --ink: #2e2620;
  --ink-dim: rgba(46, 38, 32, 0.36);
  --accent: #e07b39;
  --accent-2: #2e8b74;
  --pill: #ffd98a;
  --card: #fffdf7;
  --shadow: 0 4px 0 rgba(46, 38, 32, 0.14), 0 10px 24px rgba(46, 38, 32, 0.10);
  --radius: 24px;
  --part-a: #c25e1e;
  --part-b: #177a63;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Andika', -apple-system, 'Segoe UI', 'Helvetica Neue', sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
h1, h2, h3, .fredoka {
  font-family: 'Fredoka', 'Andika', -apple-system, 'Segoe UI', sans-serif;
}

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: var(--paper);
  border-bottom: 3px solid rgba(46,38,32,0.08);
}
#topbar-title { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 28px; flex: 1; }
#alpha-badge {
  background: var(--accent); color: #fff; font-family: 'Fredoka', sans-serif;
  font-weight: 600; font-size: 14px; letter-spacing: 0.08em;
  padding: 5px 12px; border-radius: 999px; text-transform: uppercase;
}
.icon-btn {
  min-width: 56px; min-height: 56px; border: none; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow); font-size: 28px; cursor: pointer;
}
.icon-btn:active { transform: scale(0.96); }

#app { max-width: 1180px; margin: 0 auto; padding: 18px 22px 40px; }
.loading, .load-error { font-size: 26px; text-align: center; padding: 80px 20px; }

/* ---------- home ---------- */
.home-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 26px; }
.home-card {
  border: none; cursor: pointer; text-align: center;
  background: var(--card); border-radius: 32px; box-shadow: var(--shadow);
  padding: 44px 18px 36px; min-height: 340px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.home-card:active { transform: scale(0.98); }
.home-card .hc-emoji { font-size: 96px; line-height: 1; }
.home-card .hc-title { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 34px; }
.home-card .hc-sub { font-size: 20px; color: rgba(46,38,32,0.65); }
.home-hello { font-size: 40px; font-weight: 700; text-align: center; margin-top: 22px; }

/* ---------- generic buttons ---------- */
.big-btn {
  border: none; cursor: pointer; min-height: 72px; padding: 14px 30px;
  border-radius: 999px; background: var(--accent-2); color: #fff;
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 24px;
  box-shadow: var(--shadow);
}
.big-btn.secondary { background: var(--card); color: var(--ink); }
.big-btn.accent { background: var(--accent); }
.big-btn:active { transform: scale(0.97); }
.big-btn[disabled] { opacity: 0.45; }

/* ---------- story picker ---------- */
.picker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 18px; }
.picker-card {
  border: none; cursor: pointer; text-align: left;
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow);
  padding: 26px 24px; min-height: 190px;
  display: flex; flex-direction: column; gap: 10px; justify-content: center;
}
.picker-card:active { transform: scale(0.98); }
.picker-card .pc-emoji { font-size: 52px; }
.picker-card .pc-title { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 28px; line-height: 1.15; }
.picker-card .pc-lesson { font-size: 19px; color: rgba(46,38,32,0.6); }
.section-title { font-size: 36px; font-weight: 700; margin: 8px 0 2px; }
.section-sub { font-size: 20px; color: rgba(46,38,32,0.6); margin: 0; }

/* ---------- story reader ---------- */
.reader-wrap { padding-bottom: 150px; }
.reader-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.reader-title { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 32px; flex: 1; }
.reader-text {
  background: var(--paper-2); border-radius: 28px; padding: 34px 38px 44px;
  box-shadow: inset 0 0 0 3px rgba(46,38,32,0.05);
  touch-action: pan-y;
}
.reader-line { margin: 0 0 26px; }
.reader-line:last-child { margin-bottom: 0; }
.word {
  font-size: 46px; letter-spacing: 0.04em; line-height: 1.7; color: var(--ink-dim);
  padding: 2px 7px; margin: 0 -1px; border-radius: 16px;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
}
.word.lit { color: var(--ink); background: var(--pill); box-shadow: 0 3px 0 rgba(46,38,32,0.15); }
.word .p0 { color: rgba(194, 94, 30, 0.55); }
.word .p1 { color: rgba(23, 122, 99, 0.55); }
.word.lit .p0 { color: var(--part-a); }
.word.lit .p1 { color: var(--part-b); }
.word .fl { font-weight: 700; }
.word .hyph { color: rgba(46,38,32,0.45); }
.word.lit .hyph { color: rgba(46,38,32,0.6); }
.reader-dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 50;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: rgba(255, 253, 247, 0.96); padding: 12px 14px; border-radius: 999px;
  box-shadow: 0 8px 28px rgba(46,38,32,0.22);
  max-width: 94vw;
}
.reader-dock .dock-word {
  border: none; cursor: pointer; min-height: 72px; padding: 10px 26px; border-radius: 999px;
  background: var(--accent); color: #fff; font-family: 'Fredoka', sans-serif;
  font-weight: 600; font-size: 25px; white-space: nowrap;
}
.reader-dock .dock-story {
  border: none; cursor: pointer; min-height: 72px; padding: 10px 24px; border-radius: 999px;
  background: var(--accent-2); color: #fff; font-family: 'Fredoka', sans-serif;
  font-weight: 600; font-size: 22px; white-space: nowrap;
}
.reader-dock .dock-next {
  border: 3px solid var(--accent-2); cursor: pointer; min-height: 72px; padding: 10px 24px; border-radius: 999px;
  background: var(--card); color: var(--ink); font-family: 'Fredoka', sans-serif;
  font-weight: 700; font-size: 24px; white-space: nowrap;
}
.reader-dock button:active { transform: scale(0.97); }
.the-end { text-align: center; padding: 60px 20px 30px; }
.the-end .te-star { font-size: 92px; }
.the-end h2 { font-size: 46px; margin: 10px 0 24px; }
.the-end .te-row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ---------- bundle board ---------- */
.bundle-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-top: 20px; }
.board-card {
  border: none; cursor: pointer; text-align: center; position: relative;
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow);
  padding: 18px 14px 20px; min-height: 218px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.board-card:active { transform: scale(0.98); }
.board-card .bc-pic { width: 100%; height: 118px; border-radius: 18px; overflow: hidden; background: #ffe9c4; }
.board-card .bc-pic svg { width: 100%; height: 100%; display: block; }
.board-card .bc-pic img { width: 100%; height: 100%; display: block; object-fit: cover; }
.board-card .bc-title { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 23px; line-height: 1.15; }
.board-card .bc-state { font-size: 16px; color: rgba(46,38,32,0.55); }
.board-card.cover-card { grid-column: span 4; min-height: 0; flex-direction: row; text-align: left; padding: 22px 26px; }
.board-card.cover-card .bc-pic { width: 300px; height: 150px; flex: none; }
.board-card.cover-card .bc-title { font-size: 30px; }
.board-card.cover-card .bc-sub { font-size: 19px; color: rgba(46,38,32,0.6); }
.board-card .done-badge {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  background: var(--accent-2); color: #fff; font-family: 'Fredoka', sans-serif; font-weight: 700;
  font-size: 17px; padding: 5px 13px; border-radius: 999px;
}
.board-card.slot-card {
  background: transparent; box-shadow: none; cursor: default;
  border: 4px dashed rgba(46,38,32,0.3); color: rgba(46,38,32,0.55);
  align-items: center; justify-content: center;
}
.board-card.slot-card .bc-title { color: rgba(46,38,32,0.55); font-size: 21px; }
.slot-emoji { font-size: 52px; opacity: 0.6; }

/* ---------- picture-card player ---------- */
.player { max-width: 900px; margin: 0 auto; }
.player-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.player-title { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 30px; flex: 1; }
.player-stage {
  background: var(--card); border-radius: 32px; box-shadow: var(--shadow);
  overflow: hidden;
}
.player-art { width: 100%; aspect-ratio: 16 / 9; background: #ffe9c4; }
.player-art svg { width: 100%; height: 100%; display: block; }
.player-art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.player-caption {
  font-size: 31px; line-height: 1.45; padding: 24px 34px 8px; min-height: 128px;
}
.player-controls {
  display: flex; align-items: center; gap: 20px; padding: 14px 22px 24px; flex-wrap: wrap;
}
/* per-card Hear-it is a wide, unmissable target, well clear of the arrows */
.player-controls .hear-btn { flex: 1 1 240px; min-height: 76px; font-size: 25px; }
.nav-arrow {
  border: none; cursor: pointer; width: 76px; height: 76px; border-radius: 50%;
  background: var(--paper); box-shadow: var(--shadow); font-size: 34px; color: var(--ink);
}
.nav-arrow:active { transform: scale(0.95); }
.nav-arrow[disabled] { opacity: 0.35; }
.hear-btn {
  border: none; cursor: pointer; min-height: 72px; padding: 12px 26px; border-radius: 999px;
  background: var(--accent); color: #fff; font-family: 'Fredoka', sans-serif;
  font-weight: 600; font-size: 23px; box-shadow: var(--shadow);
}
.hear-btn.play-all { background: var(--accent-2); }
.hear-btn:active { transform: scale(0.97); }
.dots { display: flex; gap: 9px; align-items: center; margin-left: auto; }
.dot { width: 17px; height: 17px; border-radius: 50%; background: rgba(46,38,32,0.18); }
.dot.on { background: var(--accent); }
.parent-strip { margin-top: 18px; background: var(--paper-2); border-radius: 22px; padding: 6px 22px; }
.parent-strip summary {
  cursor: pointer; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 21px;
  padding: 14px 0; min-height: 48px;
}
.parent-strip p { font-size: 20px; line-height: 1.5; margin: 0 0 18px; }
.finish-box { text-align: center; padding: 54px 24px 46px; }
.finish-box .fb-emoji { font-size: 84px; }
.finish-box h2 { font-size: 38px; margin: 8px 0 22px; }
/* the finish screen's one primary action */
.finish-box .board-cta {
  background: var(--accent); font-size: 27px; min-height: 88px; padding: 18px 36px;
}
.finish-box .te-row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ---------- build the word ---------- */
.btw { max-width: 900px; margin: 0 auto; text-align: center; }
.btw-prompt { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0 6px; flex-wrap: wrap; }
.btw-prompt .btw-word { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 44px; }
.btw-progress { font-size: 19px; color: rgba(46,38,32,0.55); }
.boxes { display: flex; gap: 16px; justify-content: center; margin: 26px 0 8px; }
.box {
  width: 104px; height: 118px; border-radius: 22px; border: 5px dashed rgba(46,38,32,0.35);
  background: var(--paper-2); font-family: 'Andika', sans-serif; font-weight: 700; font-size: 62px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink);
}
.box.filled { border-style: solid; border-color: var(--accent-2); background: #dff3ec; }
.box.next { border-color: var(--accent); }
.bank { display: flex; gap: 16px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }
.tile {
  width: 104px; height: 118px; border: none; border-radius: 22px; cursor: pointer;
  font-family: 'Andika', sans-serif; font-weight: 700; font-size: 62px; color: var(--ink);
  box-shadow: var(--shadow);
}
.tile:active { transform: scale(0.96); }
.tile.used { visibility: hidden; }
.tile.t0 { background: #ffd98a; } .tile.t1 { background: #ffb3a0; }
.tile.t2 { background: #a8dcc3; } .tile.t3 { background: #a9c8ec; }
@keyframes tile-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-9px); } 75% { transform: translateX(9px); } }
.tile.shake { animation: tile-shake 0.32s ease 1; }
@keyframes tile-pulse { 0% { box-shadow: 0 0 0 0 rgba(224,123,57,0.85); } 100% { box-shadow: 0 0 0 26px rgba(224,123,57,0); } }
.tile.pulse { animation: tile-pulse 0.7s ease-out 1; }
.btw-success { padding: 44px 20px; }
.btw-success .fb-emoji { font-size: 88px; }
.btw-success h2 { font-size: 40px; margin: 10px 0 24px; }

/* small screens: don't break, just stack */
@media (max-width: 900px) {
  .home-cards, .picker-grid { grid-template-columns: 1fr 1fr; }
  .bundle-board { grid-template-columns: 1fr 1fr; }
  .board-card.cover-card { grid-column: span 2; }
  .word { font-size: 38px; }
}

/* ---------------- rewards ---------------- */
.hc-reward { font-size: 21px; font-weight: 600; color: #a86e00; letter-spacing: 2px; }
.picker-card { position: relative; }
.pc-star { position: absolute; top: 14px; right: 18px; font-size: 34px; }
.te-reward { margin-bottom: 18px; }
.te-earned { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 30px; color: #a86e00; }
.te-stars { font-size: 30px; letter-spacing: 4px; margin-top: 6px; }
.the-end .te-star.pop { animation: star-pop 0.7s ease; display: inline-block; }
@keyframes star-pop {
  0% { transform: scale(0.4) rotate(-18deg); }
  55% { transform: scale(1.35) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.board-trophy {
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 30px; text-align: center;
  background: #fdf3d8; border: 3px solid #f2c230; border-radius: 22px;
  padding: 16px 20px; margin: 0 0 20px; color: #7a5200;
}
.btw-stars { text-align: center; font-size: 30px; letter-spacing: 5px; margin-top: 4px; }
.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 80; }
.confetti-bit {
  position: absolute; top: -16px; width: 13px; height: 18px; border-radius: 3px;
  animation-name: confetti-fall; animation-timing-function: ease-in; animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(108vh) rotate(560deg); opacity: 0.85; }
}
@media (prefers-reduced-motion: reduce) {
  .confetti-bit { animation-duration: 0.01s !important; }
  .the-end .te-star.pop { animation: none; }
}
.the-end .te-star.dim { opacity: 0.3; filter: grayscale(1); }
.the-end .finish-btn { display: block; margin: 2px auto 14px; font-size: 27px; padding: 18px 34px; }

/* ---------------- round 2: setup, turns, discovery ---------------- */
.setup-chips {
  display: flex; gap: 14px; justify-content: center; margin-top: 20px; flex-wrap: wrap;
}
.setup-chip {
  border: 3px solid rgba(46,38,32,0.18); cursor: pointer; min-height: 64px;
  padding: 10px 26px; border-radius: 999px; background: var(--card);
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 23px; color: var(--ink);
}
.setup-chip.on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; box-shadow: var(--shadow); }
.setup-chip:active { transform: scale(0.97); }

.turn-banner {
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 26px; text-align: center;
  background: #fdf3d8; border: 3px solid #f2c230; border-radius: 999px;
  padding: 10px 22px; margin: 4px auto 16px; max-width: 480px; color: #7a5200;
}

/* gentle pulse on Finish until the first star is ever claimed */
@keyframes finish-pulse {
  /* box-shadow only: a transform here would keep the button's box moving
     forever, which blocks automated taps and can jitter touch targets */
  0%, 100% { box-shadow: 0 4px 0 rgba(46,38,32,0.14), 0 0 0 0 rgba(224,123,57,0.55); }
  50% { box-shadow: 0 4px 0 rgba(46,38,32,0.14), 0 0 0 18px rgba(224,123,57,0); }
}
.finish-btn.finish-pulse { animation: finish-pulse 1.6s ease-in-out infinite; }
.te-christina { margin-bottom: 18px; }
.te-christina:empty { margin-bottom: 0; }
.christina-btn { background: var(--accent); }

/* ---------------- round 2: build the word ---------------- */
.btw-nav {
  display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap;
}
.btw-nav .btw-progress { flex: 0 1 auto; }
.btw-nav .nav-arrow { width: 64px; height: 64px; font-size: 29px; }
.btw-words-btn { background: var(--accent-2); }
.pc-word { font-family: 'Andika', sans-serif; font-weight: 700; font-size: 52px; text-align: center; }
.btw-picker .picker-card { align-items: center; min-height: 150px; }

/* ---------------- round 2: find the letter ---------------- */
.ftl { max-width: 900px; margin: 0 auto; text-align: center; }
.ftl-sound {
  border: none; cursor: pointer; width: 120px; height: 120px; border-radius: 50%;
  background: var(--accent); font-size: 58px; box-shadow: var(--shadow); margin: 14px 0 6px;
}
.ftl-sound:active { transform: scale(0.95); }
.ftl-tiles { display: flex; gap: 20px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.ftl-tile { width: 128px; height: 142px; font-size: 76px; }
.ftl-count { font-size: 20px; color: rgba(46,38,32,0.55); margin-top: 26px; }

@media (prefers-reduced-motion: reduce) {
  .finish-btn.finish-pulse { animation: none; }
}
