/* ReadStart — kid-friendly bright UI */

:root {
  --bg: #fff7ed;
  --ink: #2b2b2b;
  --soft: #ffe4b5;
  --primary: #ff7a59;
  --primary-ink: #fff;
  --accent: #06d6a0;
  --warn: #ef476f;
  --gold: #ffd166;
  --blue: #118ab2;
  --shadow: 0 6px 0 rgba(0,0,0,.12), 0 12px 24px rgba(0,0,0,.08);
  --radius: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Comic Sans MS", "Baloo 2", "Quicksand", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 720px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 12px;
}
.iconbtn {
  background: #fff;
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.iconbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  box-shadow: var(--shadow);
}
.profile-chip .avatar { font-size: 28px; }
.profile-chip .name { font-weight: 800; font-size: 16px; }

/* ---------- screen ---------- */
.screen {
  flex: 1;
  padding: 16px 20px 32px;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h1, h2 { margin: 8px 0 16px; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
.muted { color: #7a7a7a; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  border: 0;
  background: var(--primary);
  color: var(--primary-ink);
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  padding: 16px 26px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  letter-spacing: .3px;
  transition: transform .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.btn.ghost { background: #fff; color: var(--ink); }
.btn.accent { background: var(--accent); }
.btn.gold { background: var(--gold); color: #2b2b2b; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }

/* ---------- profile picker ---------- */
.profiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  padding: 8px 0 24px;
}
.profile-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  border: 0;
  font-family: inherit;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform .12s;
}
.profile-card:hover { transform: translateY(-2px); }
.profile-card .av { font-size: 56px; line-height: 1; }
.profile-card .nm { font-size: 18px; }
.profile-card.add { background: linear-gradient(135deg, var(--gold), var(--primary)); color: #fff; }
.profile-card .delete-x {
  position: absolute;
  margin-top: -18px;
  margin-left: 92px;
  background: var(--warn);
  color: #fff;
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 900;
  font-size: 14px;
}

/* new-profile form */
.form-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.input {
  width: 100%;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  border: 3px solid var(--soft);
  border-radius: 16px;
  padding: 12px 16px;
  outline: none;
}
.input:focus { border-color: var(--primary); }
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.avatar-grid button {
  background: var(--soft);
  border: 0;
  font-size: 28px;
  height: 52px;
  border-radius: 14px;
  cursor: pointer;
}
.avatar-grid button.sel { background: var(--gold); outline: 3px solid var(--primary); }

/* ---------- home / level map ---------- */
.greeting { font-size: 26px; font-weight: 900; margin-bottom: 4px; }
.island {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  border-top: 8px solid var(--gold);
}
.island.locked { opacity: .55; }
.island-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.island-title { font-weight: 900; font-size: 20px; }
.island-sub { color: #7a7a7a; font-weight: 600; font-size: 14px; }
.activities { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.activity-tile {
  background: var(--soft);
  border: 0;
  border-radius: 18px;
  padding: 16px 8px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform .12s;
}
.activity-tile:hover { transform: translateY(-2px); }
.activity-tile .ico { font-size: 38px; }
.activity-tile .lbl { font-size: 15px; }
.activity-tile .stars { font-size: 14px; letter-spacing: 2px; }
.activity-tile.locked { opacity: .5; cursor: not-allowed; }

/* ---------- activity screens ---------- */
.activity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 12px;
}
.bigprompt { font-size: 96px; line-height: 1; user-select: none; }
.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 460px;
}
.choice {
  background: #fff;
  border: 0;
  border-radius: 22px;
  padding: 28px 12px;
  font-family: inherit;
  font-weight: 900;
  font-size: 32px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .1s;
}
.choice:hover { transform: translateY(-2px); }
.choice.right { background: var(--accent); color: #fff; animation: pop .25s ease; }
.choice.wrong { background: #ffe2ea; outline: 3px solid var(--warn); animation: shake .25s; }
@keyframes pop { 0% { transform: scale(.9); } 100% { transform: none; } }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.progressbar {
  width: 100%;
  max-width: 460px;
  height: 14px;
  background: #fff;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.08);
}
.progressbar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--primary));
  transition: width .3s ease;
}
.streak {
  font-weight: 900;
  font-size: 20px;
  color: var(--warn);
  min-height: 28px;
}

/* sight word card */
.flashcard {
  background: #fff;
  border-radius: var(--radius);
  padding: 50px 30px;
  box-shadow: var(--shadow);
  font-size: 64px;
  font-weight: 900;
  text-align: center;
  min-width: 260px;
  cursor: pointer;
}

/* story */
.story {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  font-size: 24px;
  line-height: 1.6;
  font-weight: 700;
  width: 100%;
  max-width: 520px;
}
.story .word {
  display: inline-block;
  margin: 2px 4px;
  padding: 2px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.story .word.hl { background: var(--gold); }
.story .word:hover { background: var(--soft); }

/* spelling */
.slots, .tray {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.slot, .tile {
  width: 56px;
  height: 64px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  user-select: none;
}
.slot { background: #fff; border: 3px dashed #d8c3a5; }
.slot.filled { border-style: solid; border-color: var(--accent); }
.tile {
  background: var(--gold);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.tile.used { opacity: .25; pointer-events: none; }

/* reward */
.reward {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.reward .stars { font-size: 76px; letter-spacing: 8px; }
.reward .stars span { display: inline-block; animation: pop .4s ease both; }
.reward .stars span:nth-child(2) { animation-delay: .15s; }
.reward .stars span:nth-child(3) { animation-delay: .3s; }
.reward h1 { font-size: 36px; }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute;
  width: 10px;
  height: 14px;
  top: -20px;
  animation: fall 1.4s linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ---------- audio debug overlay ---------- */
.dbg-panel {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  max-width: 720px;
  margin: 0 auto;
  background: #1d1d1f;
  color: #fff;
  border-radius: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  z-index: 9999;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  overflow: hidden;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
}
.dbg-panel.collapsed .dbg-list,
.dbg-panel.collapsed .dbg-help { display: none; }
.dbg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #2a2a2c;
  flex-wrap: wrap;
}
.dbg-head strong { font-size: 13px; }
.dbg-count { color: #ffd166; }
.dbg-btn {
  background: #3a3a3c;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}
.dbg-btn:hover { background: #4a4a4c; }
.dbg-list {
  overflow-y: auto;
  padding: 4px 0;
}
.dbg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #2a2a2c;
}
.dbg-row.bad { background: rgba(239,71,111,.18); }
.dbg-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}
.dbg-source { font-size: 14px; }
.dbg-play, .dbg-bad {
  background: transparent;
  border: 1px solid #4a4a4c;
  color: #fff;
  width: 32px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.dbg-play:hover { background: #06d6a0; border-color: #06d6a0; }
.dbg-bad:hover  { background: #ef476f; border-color: #ef476f; }
.dbg-row.bad .dbg-bad { background: #ef476f; border-color: #ef476f; }
.dbg-help {
  padding: 6px 10px;
  background: #2a2a2c;
  color: #aaa;
  font-size: 11px;
}

/* mascot wave */
.mascot {
  font-size: 64px;
  display: inline-block;
  animation: wave 1.6s ease-in-out infinite;
  transform-origin: 70% 100%;
}
@keyframes wave {
  0%, 100% { transform: rotate(-4deg); }
  50%      { transform: rotate(8deg); }
}
