/* Sukem Reads: the new look. Four reader themes share one layout; the grown-up page uses Classic Lavender. */
:root, [data-theme="lavender"] {
  --bg: #f4f0ff; --card: #ffffff; --soft: #ece6ff; --line: #e4dbff;
  --ink: #241b4b; --sub: #4b4370; --muted: #6a5fa0;
  --accent: #7b5cf0; --accent-2: #8f74ff; --accent-ink: #ffffff;
  --cta: #ffb27a; --cta-ink: #3a1d06; --dark: #241b4b; --dark-ink: #ffffff;
  --blob-1: #e4dbff; --blob-2: #ffe3d1; --link: #5a3fd0;
  --hero: #7b5cf0; --hero-ink: #ffffff; --hero-sub: #f1ecff; --glow: none;
  --ok: #15803d; --ok-bg: #dcfce7; --bad: #b42318; --bad-bg: #fde7e7; --warn-bg: #fef3c7; --warn: #92400e;
  --shadow: 0 8px 22px rgba(90, 63, 208, 0.10);
  --meter: #ffb27a; --nav: #241b4b; --nav-ink: #ffffff;
}
[data-theme="unicorn"] {
  --bg: #fff0f7; --soft: #ffe0ef; --line: #ffd0e6; --ink: #3d1838; --sub: #74466d; --muted: #8a5a82;
  --accent: #e2589f; --accent-2: #ff9ecb; --cta: #ffd36e; --cta-ink: #4a2a00; --dark: #5b2a6e;
  --blob-1: #ffd6ea; --blob-2: #d7ecff; --link: #b8327a; --hero: linear-gradient(135deg, #ff9ecb, #a9c8ff);
  --hero-ink: #3d1838; --hero-sub: #5c2c55; --meter: #e2589f; --nav: #5b2a6e; --shadow: 0 8px 22px rgba(226, 88, 159, 0.14);
}
[data-theme="popstar"] {
  --bg: #1b1035; --card: #2d1a5c; --soft: #3a2470; --line: #4a3285; --ink: #ffffff; --sub: #d9cdf5; --muted: #b9a8e6;
  --accent: #ff4fa3; --accent-2: #46e0ff; --cta: #ff4fa3; --cta-ink: #ffffff; --dark: #46e0ff; --dark-ink: #1b1035;
  --blob-1: rgba(255, 79, 163, 0.18); --blob-2: rgba(70, 224, 255, 0.14); --link: #ff8fc8;
  --hero: #ff4fa3; --hero-ink: #ffffff; --hero-sub: #ffe6f2; --glow: 0 0 40px rgba(255, 79, 163, 0.45);
  --meter: #46e0ff; --nav: #2d1a5c; --nav-ink: #ffffff;
  --ok-bg: #12452a; --ok: #8ff0b4; --bad-bg: #4d1530; --bad: #ffb3cf; --warn-bg: #4a3a12; --warn: #ffe08a;
  --shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
[data-theme="monster"] {
  --bg: #e8fbf6; --soft: #d3f5ec; --line: #bdeedf; --ink: #17363a; --sub: #3c5e60; --muted: #557a7b;
  --accent: #2bb3a3; --accent-2: #b57cff; --cta: #ff8a3d; --cta-ink: #3a1600; --dark: #17363a;
  --blob-1: #c4f1e4; --blob-2: #ffe1cc; --link: #13796d; --hero: #2bb3a3; --hero-ink: #ffffff; --hero-sub: #e3fff8; --meter: #ff8a3d; --nav: #17363a;
  --shadow: 0 8px 22px rgba(23, 54, 58, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: "Andika", system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg);
  font-size: 20px; line-height: 1.45; min-height: 100vh; overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, h3, .f { font-family: "Fredoka", "Andika", sans-serif; font-weight: 600; line-height: 1.12; margin: 0; }
h1 { font-weight: 700; font-size: 2.2em; }
h2 { font-size: 1.5em; }
p { margin: 0; }
a { color: var(--link); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea, select {
  font: inherit; color: var(--ink); width: 100%; padding: 14px 18px; border-radius: 18px;
  border: 2px solid var(--line); background: var(--card);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.center { text-align: center; }
.muted { color: var(--sub); }
.small { font-size: 0.82em; }
.tiny { font-size: 0.68em; }
.hidden { display: none !important; }

/* page frame: decorative blobs, centered column, bottom bar space */
.blob { position: fixed; border-radius: 50%; z-index: -1; pointer-events: none; }
.blob.b1 { width: 440px; height: 440px; background: var(--blob-1); top: -220px; right: -160px; }
.blob.b2 { width: 260px; height: 260px; background: var(--blob-2); bottom: -120px; left: -90px; }
.screen { position: relative; max-width: 860px; margin: 0 auto; padding: 28px 28px 120px; display: flex; flex-direction: column; gap: 22px; }
.screen.mid { min-height: 100vh; justify-content: center; align-items: center; text-align: center; padding-bottom: 60px; }
.screen.has-nav { padding-bottom: 140px; }
.head { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.head p { color: var(--sub); }
.back {
  position: absolute; top: 24px; left: 20px; width: 60px; height: 60px; border-radius: 50%; background: var(--card);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); z-index: 3;
}
.back svg { stroke: var(--ink); }
.top-gap { margin-top: 56px; }

/* buttons */
.cta {
  display: inline-flex; align-items: center; gap: 14px; background: var(--cta); color: var(--cta-ink);
  font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 24px; min-height: 76px; padding: 0 10px 0 32px;
  border-radius: 40px; text-decoration: none; transition: transform .08s;
}
.cta .go { width: 58px; height: 58px; border-radius: 50%; background: var(--dark); display: flex; align-items: center; justify-content: center; }
.cta .go svg { stroke: var(--dark-ink); }
.cta:active, .btn:active { transform: scale(0.97); }
.cta:disabled, .btn:disabled { opacity: .45; cursor: default; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 10px 24px;
  border-radius: 999px; font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 19px;
  background: var(--card); border: 2px solid var(--line); color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--dark); border-color: var(--dark); color: var(--dark-ink); }
.btn.warm { background: var(--cta); border-color: var(--cta); color: var(--cta-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--sub); }
.btn.sm { min-height: 42px; padding: 6px 16px; font-size: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.c { justify-content: center; }
.row.sb { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.card { position: relative; background: var(--card); border-radius: 30px; padding: 24px; box-shadow: var(--shadow); }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 15px; padding: 5px 13px;
  border-radius: 999px; background: var(--soft); color: var(--ink); white-space: nowrap;
}
.chip .dot { width: 11px; height: 11px; border-radius: 50%; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.tabs { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tab {
  min-height: 52px; padding: 0 24px; border-radius: 999px; border: 2px solid var(--line); background: var(--card);
  font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 19px;
}
.tab.on { background: var(--dark); border-color: var(--dark); color: var(--dark-ink); }

/* avatars + placeholder art */
.av {
  width: 76px; height: 76px; border-radius: 50%; background: var(--soft); border: 3px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-size: 40px; flex-shrink: 0;
}
.av.xl { width: 130px; height: 130px; font-size: 70px; }
.av.lg { width: 104px; height: 104px; font-size: 56px; }
.av.sm { width: 48px; height: 48px; font-size: 26px; border-width: 2px; }

/* bottom bar (docked, small) */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(860px, 100%); z-index: 10;
  height: calc(72px + env(safe-area-inset-bottom)); padding: 0 24px env(safe-area-inset-bottom);
  background: var(--nav); border-radius: 26px 26px 0 0; display: grid; grid-template-columns: repeat(4, 1fr);
}
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none;
  color: var(--nav-ink); opacity: .7; font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 14px; }
.nav a.on { opacity: 1; }
.nav a .i { font-size: 24px; line-height: 1; }
.nav a.on .i { transform: scale(1.12); }

/* home */
.hello { display: flex; align-items: center; gap: 18px; }
.hello .who { display: flex; flex-direction: column; gap: 2px; }
.hello .who b { font-family: "Fredoka", sans-serif; font-size: 34px; font-weight: 700; }
.hello .idbtn { margin-left: auto; align-self: flex-start; }
.hero {
  position: relative; background: var(--hero); color: var(--hero-ink); border-radius: 34px; padding: 26px 30px;
  display: flex; align-items: center; gap: 20px; overflow: hidden; box-shadow: var(--glow);
}
.hero .t { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 30px; }
.hero .s { color: var(--hero-sub); font-size: 18px; }
.meter { height: 18px; border-radius: 999px; background: rgba(255,255,255,.95); margin-top: 8px; position: relative; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--meter); }
.meter-ends { display: flex; justify-content: space-between; font-size: 15px; font-weight: 700; color: var(--hero-sub); margin-top: 4px; }
.hero .badge { width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.18); display: flex; align-items: center;
  justify-content: center; font-size: 64px; flex-shrink: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat { background: var(--card); border-radius: 24px; padding: 16px 18px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat b { font-family: "Fredoka", sans-serif; font-size: 28px; font-weight: 600; }
.stat span { font-size: 15px; color: var(--sub); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); text-align: center; }
.tile .i { width: 96px; height: 96px; border-radius: 50%; background: var(--soft); display: flex; align-items: center; justify-content: center; font-size: 46px; }
.tile b { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 18px; }
.banner { display: flex; align-items: center; gap: 16px; padding: 18px 22px; border-radius: 26px; background: var(--card);
  box-shadow: var(--shadow); text-align: left; width: 100%; border: 3px solid var(--accent-2); }
.banner .e { font-size: 44px; }
.banner b { display: block; font-family: "Fredoka", sans-serif; font-size: 22px; }
.continue { display: flex; align-items: center; gap: 18px; text-align: left; width: 100%; }
.continue .cv { width: 90px; height: 90px; border-radius: 22px; flex-shrink: 0; background-size: cover; background-position: center; }

/* library */
.books { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.book { text-align: left; background: var(--card); border-radius: 30px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); color: var(--ink); }
.book .cv { height: 180px; position: relative; display: flex; align-items: flex-end; padding: 14px; background-size: cover; background-position: center; }
.book .cv .tt { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 22px; color: #241b4b; background: rgba(255,255,255,.75); border-radius: 14px; padding: 4px 10px; }
.book .ring { position: absolute; top: 12px; right: 12px; width: 58px; height: 58px; border-radius: 50%; background: #fff; color: #241b4b;
  border: 5px solid var(--accent-2); display: flex; align-items: center; justify-content: center; font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 15px; }
.book .info { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.book .info .name { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 22px; line-height: 1.15; }
.empty { text-align: center; color: var(--sub); padding: 40px 10px; }

/* reading */
.page { width: min(640px, 100%); background: var(--card); border-radius: 36px; padding: 24px; display: flex; flex-direction: column; gap: 22px; box-shadow: var(--shadow); margin: 0 auto; }
.page .pic { width: 100%; aspect-ratio: 4/3; border-radius: 26px; background: var(--soft) center/cover; display: flex; align-items: center; justify-content: center; font-size: 80px; }
.page .txt { font-size: 32px; line-height: 1.6; margin: 0 8px; }
.page .end { font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 30px; color: var(--accent); text-align: center; }
.dots { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dots span { width: 10px; height: 10px; border-radius: 999px; background: var(--line); }
.dots span.on { background: var(--accent-2); }
.dots span.here { width: 26px; background: var(--accent-2); }
.turn { position: fixed; top: 50%; transform: translateY(-50%); width: 80px; height: 80px; border-radius: 50%; background: var(--dark);
  display: flex; align-items: center; justify-content: center; z-index: 4; box-shadow: 0 10px 24px rgba(36,27,75,.25); }
.turn svg { stroke: var(--dark-ink); }
.turn.l { left: max(12px, calc(50% - 470px)); }
.turn.r { right: max(12px, calc(50% - 470px)); }
.turn:disabled { opacity: .25; }

/* quiz */
.qbar { width: min(600px, 100%); height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 0 auto; }
.qbar i { display: block; height: 100%; background: var(--accent-2); border-radius: 999px; }
.qnums { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.qnum { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); font-family: "Fredoka", sans-serif; font-weight: 600; }
.qnum.done { background: var(--soft); border-color: var(--accent-2); }
.qnum.here { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.prompt { font-size: 32px; line-height: 1.35; text-align: center; font-weight: 700; }
.choices { display: flex; flex-direction: column; gap: 14px; width: min(640px, 100%); margin: 0 auto; }
.choice { display: flex; align-items: center; gap: 18px; text-align: left; padding: 16px 22px; border-radius: 24px; border: 3px solid var(--line);
  background: var(--card); font-size: 26px; min-height: 84px; color: var(--ink); }
.choice .l { width: 48px; height: 48px; flex-shrink: 0; border-radius: 50%; background: var(--soft); display: flex; align-items: center; justify-content: center;
  font-family: "Fredoka", sans-serif; font-weight: 600; }
.choice.on { border-color: var(--accent-2); background: var(--soft); }
.choice.on .l { background: var(--accent-2); color: #fff; }
.qnav { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: min(640px, 100%); margin: 0 auto; }
.checklist { display: flex; flex-direction: column; gap: 10px; width: min(640px, 100%); margin: 0 auto; }
.checkrow { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); text-align: left; width: 100%; }
.checkrow .n { width: 40px; height: 40px; border-radius: 50%; background: var(--soft); display: flex; align-items: center; justify-content: center; font-family: "Fredoka", sans-serif; font-weight: 600; flex-shrink: 0; }
.checkrow .a { flex: 1; }
.big-score { font-family: "Fredoka", sans-serif; font-size: 72px; font-weight: 700; color: var(--accent); }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(560px, 100%); }
.rate button { background: var(--card); border: 3px solid var(--line); border-radius: 24px; padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: "Fredoka", sans-serif; font-weight: 600; }
.rate button .e { font-size: 44px; }
.rate button.on { border-color: var(--accent-2); background: var(--soft); }
.watermark { position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .05; font-size: 64px; transform: rotate(-24deg);
  display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 700; color: var(--ink); }
.quiz-mode { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.veil { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 60px; }
.veil p { font-size: 24px; }

/* pin + secret pictures */
.pin-dots { display: flex; gap: 18px; justify-content: center; }
.pin-dots span { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--accent-2); }
.pin-dots span.on { background: var(--accent-2); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 96px); gap: 16px; justify-content: center; }
.pin-key { width: 96px; height: 96px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 36px; }
.shake { animation: shake .45s; }
@keyframes shake { 0%,100% { transform: none; } 20%,60% { transform: translateX(-10px); } 40%,80% { transform: translateX(10px); } }
.pics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; width: min(560px, 100%); }
.pic-btn { aspect-ratio: 1; border-radius: 26px; background: var(--card); box-shadow: var(--shadow); font-size: 52px; position: relative; border: 3px solid transparent; }
.pic-btn.on { border-color: var(--accent-2); background: var(--soft); }
.pic-btn .n { position: absolute; top: -10px; right: -10px; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 18px; font-family: "Fredoka", sans-serif; display: flex; align-items: center; justify-content: center; }
.picked { display: flex; gap: 14px; justify-content: center; min-height: 80px; }
.picked span { width: 76px; height: 76px; border-radius: 22px; border: 3px dashed var(--line); display: flex; align-items: center; justify-content: center; font-size: 42px; }
.readers { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; width: 100%; }
.reader-tile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 10px; border-radius: 30px; background: var(--card); box-shadow: var(--shadow); }
.reader-tile b { font-family: "Fredoka", sans-serif; font-size: 24px; }
.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.avatars button { aspect-ratio: 1; border-radius: 50%; background: var(--card); font-size: 46px; border: 3px solid transparent; box-shadow: var(--shadow); }
.avatars button.on { border-color: var(--accent-2); background: var(--soft); }
.code-box { font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 54px; letter-spacing: 6px; background: var(--card); border-radius: 26px; padding: 16px 28px; box-shadow: var(--shadow); }

/* star words, ask a story, leaderboard */
.word { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.word b { font-family: "Fredoka", sans-serif; font-size: 28px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.pick-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.pick { min-height: 54px; padding: 8px 20px; border-radius: 999px; background: var(--card); border: 3px solid var(--line); font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 19px; }
.pick.on { border-color: var(--accent-2); background: var(--soft); }
.suggest { display: flex; flex-direction: column; gap: 6px; }
.suggest button { text-align: left; padding: 10px 16px; border-radius: 16px; background: var(--card); border: 2px solid var(--line); }
.board { display: flex; flex-direction: column; gap: 10px; }
.board .r { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.board .r.me { border: 3px solid var(--accent-2); }
.board .rank { width: 44px; font-family: "Fredoka", sans-serif; font-size: 26px; font-weight: 700; text-align: center; }
.board .nm { flex: 1; font-family: "Fredoka", sans-serif; font-size: 22px; }
.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.theme-card { text-align: left; border: 4px solid transparent; background: var(--card); border-radius: 30px; padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); color: var(--ink); }
.theme-card.on { border-color: var(--accent); }
.theme-card .sw { height: 120px; border-radius: 22px; display: flex; align-items: flex-end; gap: 8px; padding: 14px; }
.theme-card .sw i { width: 40px; height: 40px; border-radius: 50%; }

/* pop-ups + toasts */
.overlay { position: fixed; inset: 0; background: rgba(20, 12, 45, .45); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 20px; }
.dialog { background: var(--card); color: var(--ink); border-radius: 30px; padding: 28px; width: min(520px, 100%); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog.wide { width: min(860px, 100%); }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 30px); opacity: 0; transition: .25s; z-index: 60;
  background: var(--dark); color: var(--dark-ink); padding: 14px 24px; border-radius: 999px; font-weight: 700; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .screen { padding: 20px 16px 120px; }
  .books { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .stats { gap: 8px; }
  .stat b { font-size: 22px; }
  .page .txt, .prompt { font-size: 26px; }
  .choice { font-size: 22px; min-height: 70px; }
  .pin-pad { grid-template-columns: repeat(3, 80px); }
  .pin-key { width: 80px; height: 80px; }
  .hero .badge { display: none; }
  .turn { width: 60px; height: 60px; top: auto; bottom: 90px; transform: none; }
  .themes, .avatars { grid-template-columns: repeat(2, 1fr); }
}
a.btn, a.cta { text-decoration: none; }
