:root {
  --wall: #fff1d6;
  --wall-dot: #ffe2b0;
  --ink: #3a2a1a;
  --wood-1: #d98b4a;
  --wood-2: #b8692f;
  --wood-3: #8a4a1f;
  --back-1: #f7c98f;
  --back-2: #eeb06b;
  /* Kích thước sách theo cả chiều rộng lẫn chiều cao (iPhone ngang thấp) */
  --book-w: clamp(118px, min(21vw, 30vh), 210px);
  --radius: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --btn: 54px;
  font-family: 'Baloo 2', ui-rounded, 'PingFang SC', 'Hiragino Maru Gothic ProN', 'Apple SD Gothic Neo', 'Noto Sans CJK SC', system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
/* Chỉ html cuộn; body dùng clip để không thành khung cuộn riêng (nếu không iOS/Chrome sẽ không cuộn được) */
html, body { margin: 0; min-height: 100%; }
/* Trang chủ không cuộn: kệ luôn vừa màn hình, chỉ .shelves bên trong cuộn */
html { height: 100%; overflow: hidden; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background:
    radial-gradient(circle at 12px 12px, var(--wall-dot) 5px, transparent 6px) 0 0 / 48px 48px,
    linear-gradient(#ffe7c2, var(--wall));
  background-color: var(--wall);
  overflow-x: clip;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  height: 100dvh; overflow: hidden;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ---------- Mây nền ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.cloud {
  position: absolute; width: 140px; height: 46px; background: #fff; border-radius: 50px; opacity: .8;
  animation: drift 60s linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 64px; height: 64px; left: 18px; top: -30px; }
.cloud::after { width: 50px; height: 50px; left: 66px; top: -22px; }
.c1 { top: 12%; left: -160px; }
.c2 { top: 46%; left: -160px; animation-duration: 85s; animation-delay: -30s; transform: scale(.7); }
.c3 { top: 78%; left: -160px; animation-duration: 70s; animation-delay: -55s; transform: scale(.85); }
@keyframes drift { to { translate: calc(100vw + 320px) 0; } }

/* ---------- Thanh trên (nằm trên khung gỗ phía trên của kệ) ---------- */
.topbar {
  position: relative; z-index: 2; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 12px; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { width: clamp(44px, 7vw, 60px); height: auto; filter: drop-shadow(0 4px 0 rgba(138, 74, 31, .25)); }
.brand h1 {
  margin: 0; font-size: clamp(28px, 5.4vw, 46px); font-weight: 800; line-height: 1;
  color: #fff; letter-spacing: .5px;
  text-shadow: 0 3px 0 var(--wood-3);
}
.brand h1 span { white-space: nowrap; }
.brand h1 .accent { color: #ffe08a; }
.actions { display: flex; gap: 10px; }
.round-btn {
  width: var(--btn); height: var(--btn); border-radius: 50%; flex: none;
  background: #fff; font-size: calc(var(--btn) * .44);
  box-shadow: 0 5px 0 #f0c58d, 0 8px 18px rgba(138, 74, 31, .18);
  transition: transform .12s, box-shadow .12s;
}
.round-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #f0c58d; }
/* Nút âm thanh khi tắt: nền đỏ nhạt để dễ nhận ra */
.round-btn.is-muted { background: #ffd9de; box-shadow: 0 5px 0 #f29aa7, 0 8px 18px rgba(196, 29, 75, .2); }

/* ---------- Tủ sách ---------- */
.cabinet {
  position: fixed; z-index: 1;
  top: calc(8px + var(--safe-t)); bottom: calc(8px + var(--safe-b));
  left: 50%; translate: -50% 0;
  width: min(1180px, calc(100vw - 16px - var(--safe-l) - var(--safe-r)));
  display: flex; flex-direction: column;
  padding: 12px clamp(10px, 2vw, 22px) 18px;
  border-radius: 30px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.06) 0 3px, transparent 3px 22px),
    linear-gradient(var(--wood-1), var(--wood-2));
  box-shadow: inset 0 -10px 0 var(--wood-3), inset 0 4px 0 rgba(255,255,255,.25), 0 18px 40px rgba(138, 74, 31, .28);
}
/* Vùng cuộn dọc chứa các ngăn kệ */
.shelves {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; border-radius: 18px; padding-bottom: 6px;
}
.shelves::-webkit-scrollbar { display: none; }

.shelf { position: relative; margin-top: 22px; min-width: 0; }
.shelf-box { min-width: 0; }
.shelf:first-child { margin-top: 30px; }

/* Biển tên ngăn kệ */
.shelf-sign {
  position: absolute; z-index: 3; top: -24px; left: 50%; translate: -50% 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 30px 8px; border-radius: 18px;
  background: var(--accent); color: #fff;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 70%, #000), 0 10px 18px rgba(0,0,0,.15);
  rotate: -1.5deg; white-space: nowrap;
  animation: swing 4s ease-in-out infinite;
  transform-origin: 50% -20px;
}
.shelf-sign::before, .shelf-sign::after { /* đinh */
  content: ''; position: absolute; top: 8px; width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.7);
}
.shelf-sign::before { left: 10px; } .shelf-sign::after { right: 10px; }
.sign-name { font-size: clamp(20px, 3.4vw, 28px); font-weight: 800; line-height: 1.1; }
.sign-name { white-space: nowrap; }
.sign-tag { font-size: clamp(13px, 1.9vw, 16px); font-weight: 600; opacity: .92; line-height: 1.15; text-wrap: balance; }
@keyframes swing { 50% { rotate: 1.5deg; } }

.shelf-box {
  position: relative; border-radius: 16px 16px 6px 6px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.35), transparent 60%),
    linear-gradient(var(--back-1), var(--back-2));
  box-shadow: inset 0 10px 18px rgba(138, 74, 31, .28), inset 0 0 0 3px rgba(138, 74, 31, .15);
  padding-top: 36px;
}
.shelf-row {
  display: flex; align-items: flex-end; gap: clamp(16px, 3vw, 34px);
  /* Chỉ cuộn ngang; khóa dọc để vuốt dọc trên sách vẫn cuộn được trang. Padding trên chừa chỗ cho nhãn MỚI */
  padding: 26px clamp(18px, 3vw, 34px) 0;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; touch-action: pan-x pan-y; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  min-height: calc(var(--book-w) * 1.3 + 24px);
}
.shelf-row::-webkit-scrollbar { display: none; }
.plank {
  position: relative; height: 26px; margin: 0 -8px;
  border-radius: 6px;
  background: linear-gradient(#e9a160, var(--wood-2) 55%, var(--wood-3));
  box-shadow: 0 8px 12px rgba(90, 40, 10, .3);
}
.plank::before { content: ''; position: absolute; inset: 0 0 auto; height: 5px; background: rgba(255,255,255,.3); border-radius: 6px 6px 0 0; }

/* ---------- Sách ---------- */
.book {
  position: relative; flex: 0 0 var(--book-w); aspect-ratio: 200 / 260;
  scroll-snap-align: center;
  rotate: var(--tilt);
  transform-origin: 50% 100%;
  animation: drop .6s cubic-bezier(.3, 1.6, .5, 1) var(--delay) backwards;
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.book .cover {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: 6px 16px 16px 6px;
  box-shadow:
    inset 8px 0 0 rgba(0,0,0,.12),       /* gáy */
    5px 0 0 #fffaf0, 7px 0 0 #e8dcc4,     /* mép giấy */
    10px 12px 16px rgba(80, 35, 5, .35);
}
.cover { container-type: inline-size; }
.cover img { width: 100%; height: 100%; display: block; object-fit: cover; pointer-events: none; }
.cover-title {
  position: absolute; left: 6%; right: 6%; bottom: 4.5%; min-height: 16%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 1.5cqw 5cqw; border-radius: 9cqw; background: #fff; color: var(--ink);
  font-size: 10.5cqw; font-weight: 800; line-height: 1.05; text-wrap: balance;
}
.cover-title.long { font-size: 8.6cqw; }
html:lang(ja) .cover-title, html:lang(ko) .cover-title { word-break: keep-all; }
.book::after { /* bóng trên kệ */
  content: ''; position: absolute; left: 6%; right: -6%; bottom: -6px; height: 12px;
  background: radial-gradient(ellipse, rgba(80,35,5,.35), transparent 70%); z-index: -1;
}
@media (hover: hover) { .book:hover { transform: translateY(-10px) scale(1.03); } }
.book:focus-visible { transform: translateY(-10px) scale(1.03); outline: none; }
.book:active { transform: translateY(-4px) scale(.97); }
.book.wiggle { animation: wiggle .45s ease; }
.book.is-soon .cover img { filter: saturate(.8); }

.sticker {
  position: absolute; top: -12px; right: -14px; z-index: 2;
  min-width: 52px; height: 52px; padding: 0 8px; display: grid; place-items: center;
  border-radius: 26px; background: #ff3d6e; color: #fff;
  font-size: 14px; font-weight: 800; rotate: 14deg; white-space: nowrap;
  box-shadow: 0 4px 0 #c41d4b, 0 0 0 4px #fff;
  animation: pulse 1.8s ease-in-out infinite;
}
.ribbon {
  position: absolute; z-index: 2; left: -10px; top: 12px; rotate: -10deg;
  padding: 2px 14px; border-radius: 12px; white-space: nowrap;
  background: #fff; color: #8a4a1f; font-weight: 800; font-size: clamp(13px, 1.8vw, 16px);
  box-shadow: 0 3px 0 #f0c58d;
}

@keyframes drop { from { transform: translateY(-120px); opacity: 0; } }
@keyframes wiggle { 25% { transform: rotate(-6deg) scale(1.06); } 60% { transform: rotate(5deg) scale(1.06); } }
@keyframes pulse { 50% { scale: 1.1; } }

/* Ngăn đồ chơi */
.toys .shelf-box { padding-top: 14px; }
.toys .shelf-row { min-height: 0; padding-top: 10px; justify-content: space-around; overflow: visible; flex-wrap: wrap; gap: 6px 10px; }
.toy {
  font-size: clamp(34px, 7vw, 64px); line-height: 1; cursor: pointer;
  filter: drop-shadow(4px 6px 0 rgba(80,35,5,.2));
  animation: drop .6s cubic-bezier(.3, 1.6, .5, 1) var(--delay) backwards;
}
.toy.hop { animation: hop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes hop { 40% { transform: translateY(-34px) rotate(-10deg); } }

/* ---------- Sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 16px;
  background: rgba(58, 42, 26, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .25s;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: relative; display: flex; gap: 24px; align-items: center;
  width: min(720px, 100%); padding: 26px; border-radius: 32px;
  background: #fffaf0; box-shadow: 0 10px 0 #f0c58d, 0 30px 60px rgba(0,0,0,.25);
  max-height: calc(100dvh - 40px - var(--safe-t) - var(--safe-b)); overflow-y: auto; -webkit-overflow-scrolling: touch;
  scale: .8; transition: scale .35s cubic-bezier(.3, 1.6, .5, 1);
}
.sheet.small { width: min(440px, 100%); }
.sheet.small h2 { padding-right: 52px; margin-top: 4px; }
.sheet-backdrop.open .sheet { scale: 1; }
.sheet-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 48px; height: 48px; font-size: 20px; font-weight: 800; }
.sheet-cover { flex: 0 0 min(240px, 40%); aspect-ratio: 200/260; border-radius: 8px 20px 20px 8px; overflow: hidden; box-shadow: 8px 12px 0 rgba(138,74,31,.2); rotate: -3deg; }
.sheet-cover .cover { position: relative; display: block; width: 100%; height: 100%; }
.sheet-body { flex: 1; min-width: 0; }
.sheet-series { margin: 0; font-weight: 800; font-size: 16px; text-transform: uppercase; letter-spacing: 1px; }
.sheet h2 { margin: 2px 0 8px; font-size: clamp(30px, 5vw, 42px); line-height: 1.05; }
.sheet-desc { margin: 0 0 20px; font-size: clamp(17px, 2.4vw, 21px); line-height: 1.35; }
.big-btn {
  width: 100%; padding: 14px 20px; border-radius: 24px;
  background: #ff7a45; color: #fff; font-size: clamp(20px, 3vw, 26px); font-weight: 800;
  box-shadow: 0 6px 0 #d4531f; transition: transform .12s, box-shadow .12s;
}
.big-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #d4531f; }
.big-btn.muted { background: #b9a28a; box-shadow: 0 6px 0 #8f7a64; }
.steps { padding-left: 24px; font-size: 19px; line-height: 1.7; margin: 8px 0 0; }
.ios-share { display: inline-block; padding: 0 6px; border-radius: 6px; background: #e8f0ff; color: #2f6fe0; font-weight: 800; }

/* iPad / màn hình dọc: sách to hơn */
@media (orientation: portrait) and (min-width: 601px) {
  :root { --book-w: clamp(160px, min(30vw, 24vh), 260px); }
  .toy { font-size: clamp(48px, 8vw, 80px); }
}
/* iPhone dọc */
@media (max-width: 600px) {
  :root { --book-w: clamp(140px, min(46vw, 30vh), 220px); --btn: 46px; }
  .brand-icon { width: 40px; }
  .brand h1 { font-size: clamp(22px, 6.4vw, 30px); }
  .actions { gap: 8px; }
  .cabinet { padding-inline: 10px; border-radius: 24px; }
  .shelf-sign { padding: 5px 18px 7px; max-width: calc(100% - 24px); white-space: normal; text-align: center; }
  .sheet { flex-direction: column; text-align: center; padding: 22px 18px; }
  .sheet-cover { flex-basis: auto; width: 55%; }
  .lang-btn { font-size: 18px; padding: 10px 12px; }
}
/* iPhone ngang (thấp) */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --btn: 44px; }
  .cabinet { padding-top: 6px; padding-bottom: 10px; }
  .topbar { padding-bottom: 6px; }
  .brand-icon { width: 36px; }
  .brand h1 { font-size: 26px; }
  .shelf-box { padding-top: 30px; }
  .sheet-cover { flex-basis: 30%; }
  .sheet h2 { font-size: 28px; }
}

/* Chọn ngôn ngữ */
.lang-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
.lang-btn {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 20px;
  background: #fff; font-size: 20px; font-weight: 700; text-align: start;
  box-shadow: 0 5px 0 #f0c58d, inset 0 0 0 3px #ffe2b0; transition: transform .12s, box-shadow .12s;
}
.lang-btn .flag { font-size: 30px; line-height: 1; }
.lang-btn.active { background: #ff7a45; color: #fff; box-shadow: 0 5px 0 #d4531f; }
.lang-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #f0c58d; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 20; left: 50%; bottom: calc(24px + var(--safe-b));
  translate: -50% 140%; opacity: 0;
  padding: 12px 22px; border-radius: 22px; background: var(--ink); color: #fff;
  font-size: 19px; font-weight: 700; white-space: nowrap;
  transition: translate .35s cubic-bezier(.3, 1.6, .5, 1), opacity .2s;
  pointer-events: none;
}
.toast.show { translate: -50% 0; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =========================================================
   Trang đọc sách
   ========================================================= */
body.reading { overflow: hidden; }
.reader {
  position: fixed; inset: 0; z-index: 30;
  display: grid; grid-template-rows: auto 1fr auto; grid-template-areas: "top" "main" "bottom";
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) calc(14px + var(--safe-b)) calc(12px + var(--safe-l));
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,.18), transparent 70%),
    var(--page-bg, #1a1426);
  transition: background-color .6s, opacity .3s;
  opacity: 0;
}
.reader.open { opacity: 1; }
.r-top { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.r-dots { display: flex; gap: 8px; }
.r-actions { display: flex; gap: 10px; }
.round-btn.muted { opacity: .4; }
.r-dots i { width: 12px; height: 12px; border-radius: 6px; background: rgba(255,255,255,.45); transition: width .3s, background .3s; }
.r-dots i.on { width: 30px; background: #fff; }

.r-main { grid-area: main; position: relative; min-height: 0; display: grid; place-items: center; container-type: size; }
.r-stage {
  position: relative; aspect-ratio: 1;
  width: min(100cqw - 8px, 100cqh - 8px);
  touch-action: pan-y;
}
.r-pages { position: absolute; inset: 0; perspective: 2000px; }
.r-page {
  position: absolute; inset: 0; border-radius: 22px; overflow: hidden;
  transform-origin: left center; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 12px 0 rgba(0,0,0,.15), 0 20px 40px rgba(0,0,0,.25);
  background: #fff;
}
.r-page svg { width: 100%; height: 100%; display: block; }
.r-shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: linear-gradient(90deg, rgba(0,0,0,.05), rgba(0,0,0,.45)); }
.r-page.turn-out { z-index: 2; animation: turnOut .7s cubic-bezier(.45, .05, .35, 1) forwards; }
.r-page.turn-out .r-shade { animation: shadeIn .7s forwards; }
.r-page.turn-in { z-index: 2; animation: turnIn .7s cubic-bezier(.45, .05, .35, 1) both; }
.r-page.turn-in .r-shade { animation: shadeOut .7s both; }
@keyframes turnOut { to { transform: rotateY(-180deg); } }
@keyframes turnIn { from { transform: rotateY(-180deg); } }
@keyframes shadeIn { to { opacity: 1; } }
@keyframes shadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Phần giữ nguyên: lớp cố định giữa art và over */
.r-keep { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }
.r-overs { z-index: 6; pointer-events: none; }
.r-page.over { background: none; box-shadow: none; }
.r-keep .pupil { transition: transform .15s ease-out; }
.eye.blink { animation: blink .28s ease-in-out; }
@keyframes blink { 50% { transform: scaleY(.08); } }
.creature { transform-origin: 200px 330px; }
.creature.boing { animation: boing .55s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes boing { 30% { transform: scale(1.06, .92); } 60% { transform: scale(.96, 1.06); } }

/* Sách Ú Òa: mảnh che + bạn trốn */
.flap { cursor: pointer; transition: transform .6s cubic-bezier(.3, 1.4, .5, 1), opacity .5s; animation: nudge 3.4s ease-in-out infinite; }
.flap.open { transform: var(--open); animation: none; pointer-events: none; }
.flap.open.fade { opacity: 0; }
.flap [data-crack] { opacity: 0; transition: opacity .15s; }
.flap.shake { animation: shake .4s ease-in-out; }
@keyframes shake { 25% { transform: rotate(-7deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-4deg); } }
@keyframes nudge { 0%, 80%, 100% { transform: none; } 86% { transform: rotate(-2.5deg); } 93% { transform: rotate(2.5deg); } }
.peek { transform-box: fill-box; transform-origin: 50% 100%; transform: translateY(var(--dy)) scale(.85); transition: transform .55s cubic-bezier(.3, 1.8, .5, 1); }
.peek.shown { transform: none; cursor: pointer; }
.peek.shown.boing { animation: boing .55s cubic-bezier(.3, 1.6, .5, 1); }
.r-next.hint { animation: pulse 1s ease-in-out infinite; }

.r-nav {
  position: absolute; top: 50%; translate: 0 -50%; z-index: 6;
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.92); color: var(--ink); font-size: 26px;
  box-shadow: 0 5px 0 rgba(0,0,0,.18);
  transition: opacity .2s, transform .12s;
}
.r-nav:active { transform: translateY(4px); }
.r-nav:disabled { opacity: 0; pointer-events: none; }
.r-prev { left: 4px; } .r-next { right: 4px; }

.r-bottom { grid-area: bottom; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 12px; }
.r-text {
  margin: 0; max-width: 900px; padding: 10px 26px; border-radius: 26px;
  background: #fff; color: var(--ink); text-align: center;
  font-size: clamp(22px, 3.6vw, 36px); font-weight: 800; line-height: 1.2;
  box-shadow: 0 6px 0 rgba(0,0,0,.15); cursor: pointer; text-wrap: balance;
}
.r-end { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.r-end .big-btn { width: auto; padding: 12px 22px; font-size: clamp(18px, 2.6vw, 24px); }
.big-btn.alt { background: #fff; color: var(--ink); box-shadow: 0 6px 0 rgba(0,0,0,.18); }

html:lang(ja) .r-text, html:lang(ko) .r-text, html:lang(ja) .sign-tag, html:lang(ko) .sign-tag { word-break: keep-all; }

/* Màn dọc: trang + chữ dồn vào giữa */
@media (orientation: portrait) {
  .reader { grid-template-rows: auto 1fr auto auto 1fr; grid-template-areas: "top" "." "main" "bottom" "."; }
  .r-main { container-type: normal; }
  .r-stage { width: min(100vw - 24px - var(--safe-l) - var(--safe-r), 100dvh - 300px, 820px); }
}
/* iPhone dọc: nút lật nhỏ hơn, đè lên mép trang */
@media (max-width: 600px) {
  .r-nav { width: 52px; height: 52px; font-size: 22px; }
  .r-dots { gap: 5px; min-width: 0; }
  .r-dots i { width: 8px; height: 8px; }
  .r-dots i.on { width: 18px; }
  .r-actions { gap: 8px; }
  .r-prev { left: -4px; } .r-next { right: -4px; }
  .r-text { font-size: 22px; padding: 8px 18px; }
}
/* iPhone ngang: chữ sang bên phải */
@media (max-height: 500px) and (orientation: landscape) {
  .reader { grid-template-columns: 1fr minmax(220px, 40%); grid-template-rows: auto 1fr; grid-template-areas: "top top" "main bottom"; }
  .r-bottom { justify-content: center; padding: 0 0 0 12px; }
  .r-text { font-size: 22px; }
  .r-nav { width: 48px; height: 48px; font-size: 20px; }
}

/* ---------- Ghép Hình Vui: 3 dải lật riêng ---------- */
.mix { position: absolute; inset: 0; display: grid; grid-template-rows: repeat(3, 1fr); }
.mix.boing { animation: boing .55s cubic-bezier(.3, 1.6, .5, 1); }
.m-strip { position: relative; perspective: 1400px; cursor: pointer; }
.m-strip + .m-strip::before { content: ''; position: absolute; inset: -2px 6% auto; height: 4px; z-index: 4; border-radius: 2px; background: rgba(0,0,0,.14); }
.m-leaf { position: absolute; inset: 0; background: var(--page-bg, #fff); transform-origin: left center; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.m-leaf svg { width: 100%; height: 100%; display: block; }
.m-leaf.turn-out { z-index: 2; animation: turnOut .55s cubic-bezier(.45, .05, .35, 1) forwards; }
.m-leaf.turn-in { z-index: 2; animation: turnIn .55s cubic-bezier(.45, .05, .35, 1) both; }

/* ---------- Thanh công cụ dưới trang (bảng màu, xúc xắc) ---------- */
.r-tools-slot:empty { display: none; }
.r-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; }
.tool-btn.big { width: 64px; height: 64px; border-radius: 50%; background: #fff; font-size: 34px; box-shadow: 0 5px 0 rgba(0,0,0,.18); }
.tool-btn:active, .swatch:active { transform: translateY(3px); }
.swatch {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: var(--c, #fff); border: 4px solid #fff; box-shadow: 0 4px 0 rgba(0,0,0,.18);
  font-size: 22px; line-height: 1; transition: transform .12s;
}
.swatch.on { transform: scale(1.16); outline: 4px solid var(--ink); outline-offset: 1px; }
.reader[data-mode="paint"] .r-text { font-size: clamp(18px, 2.6vw, 26px); padding: 6px 18px; }
.swatch.reset.armed { background: #ffd6d6; animation: shake .4s ease-in-out; outline: 4px solid #ff4d4d; outline-offset: 1px; }
.pz, .ps { cursor: pointer; transition: fill .15s, stroke .15s; }

/* ---------- Đố âm thanh ---------- */
.q-choice { cursor: pointer; }
.q-choice.boing { animation: boing .55s cubic-bezier(.3, 1.6, .5, 1); }
.q-choice.shake { animation: shake .4s ease-in-out; }
.q-ok { transition: opacity .2s; }

@media (orientation: portrait) {
  .reader[data-mode="paint"] .r-stage { width: min(100vw - 24px - var(--safe-l) - var(--safe-r), 100dvh - 420px, 820px); }
}
@media (max-width: 600px) {
  .swatch { width: 44px; height: 44px; border-width: 3px; }
  .r-tools { gap: 6px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .r-bottom { gap: 8px; }
  .swatch { width: 44px; height: 44px; }
}
.reader .toast { z-index: 40; }
