/* ===== Tokens — "đồ chơi nhựa": viền mực, bóng cứng, màu phẳng ===== */
:root {
  --bg: #FBF6EC;
  --card: #FFFFFF;
  --ink: #1B2340;          /* navy: chữ, viền, bóng */
  --muted: #5A6278;
  --orange: #FF7A1A;      /* nút chính, điểm nhấn */
  --orange-ink: #B84E06;  /* chữ cam trên nền kem (đạt 4.5:1) */
  --mint: #2EC4A0;
  --soft: #F1EADB;        /* nền phụ, ô trống */

  /* màu danh mục — icon bên trong luôn dùng --ink */
  --food: #FFB37A;
  --drink: #FFD84D;
  --boba: #C3A6FF;
  --ride: #7FD8C0;
  --shop: #8FB4FF;
  --more: #DCD5C6;
  --food-ink: var(--ink); --drink-ink: var(--ink); --boba-ink: var(--ink); --ride-ink: var(--ink); --shop-ink: var(--ink);

  --line: 2.5px solid var(--ink);
  --lift: 0 4px 0 var(--ink);
  --spring: cubic-bezier(.3, 1.5, .5, 1);
  --soft-spring: cubic-bezier(.2, 1.3, .4, 1);

  font-family: Nunito, system-ui, sans-serif;
  color: var(--ink);
}

/* Dynamic Type: 1rem = cỡ chữ body của hệ thống (17px mặc định, lớn theo Cài đặt › Cỡ chữ). */
html { font-size: 17px; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; font-family: Nunito, system-ui, sans-serif; } }

* { box-sizing: border-box; }
body { margin: 0; background: #E9E1D0; -webkit-tap-highlight-color: transparent; }

/* Cảm giác app native: không zoom khi chạm 2 lần, không bôi chọn chữ / menu giữ lâu trên giao diện
   (ô nhập vẫn chọn được), trang không nảy — chỉ vùng nội dung cuộn và nảy, tab bar đứng yên. */
/* Không zoom (chạm hai lần lẫn hai ngón) như app native: chỉ cho cuộn. touch-action chỉ tính từ phần tử
   được chạm lên tới vùng cuộn gần nhất (.scroll), nên đặt cho mọi phần tử. iOS còn chặn thêm bằng JS
   (gesturestart) trong index.html. */
*, html { touch-action: pan-x pan-y; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
h1, h2, h3, .num { font-family: "Baloo 2", system-ui, sans-serif; margin: 0; }
p { margin: 0; }
a { color: var(--orange-ink); text-decoration: none; font-weight: 800; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.i { width: 24px; height: 24px; flex: none; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ===== App shell =====
   Khung .app đứng yên; chỉ .scroll cuộn (nảy kiểu iOS ngay trong vùng nội dung, không lan ra trang).
   Tab bar là anh em của .scroll nên không bao giờ bị kéo theo khi cuộn hay nảy. */
/* Status bar trong suốt: nội dung cuộn tràn ra sau giờ/pin. --top = phần bị status bar che. */
:root { --top: env(safe-area-inset-top); }
/* iOS 26.1 có lúc báo inset = 0 trong app ngoài màn hình chính (WebKit 301994) → chừa tối thiểu gần bằng status bar có Dynamic Island. */
@media (display-mode: standalone) and (max-width: 599px) { :root { --top: max(env(safe-area-inset-top), 54px); } }
.app { position: relative; max-width: 430px; height: 100dvh; margin: 0 auto; background: var(--bg); overflow: hidden; }
.scroll {
  height: 100%; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; scrollbar-width: none;
  padding: calc(var(--top) + 24px) 20px 0;
  display: flex; flex-direction: column; gap: 24px;
}
.scroll::-webkit-scrollbar { display: none; }
/* Chừa chỗ cho tab bar để nội dung cuối không bị che */
.app:has(> .tab-bar) .scroll { padding-bottom: calc(env(safe-area-inset-bottom) + 100px); }
@media (max-width: 599px) {
  /* Trang không cuộn/nảy; chỉ .scroll cuộn, chạy cả ra sau status bar. */
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); }
  /* --app-h: chiều cao thật của app trên MH chính (index.html), vì iOS 26 báo thiếu ~chiều cao status bar. */
  .app { position: fixed; top: 0; left: 0; right: 0; height: var(--app-h, 100%); max-width: none; }
}
@media (min-width: 600px) {
  body { padding: 32px 0; }
  .app { width: 390px; height: 844px; border-radius: 52px; box-shadow: 0 0 0 10px var(--ink), 0 30px 60px rgba(27, 35, 64, .25); }
  .scroll { padding-top: 56px; }
}

/* ===== Khối đồ chơi ===== */
.toy { background: var(--card); border: var(--line); border-radius: 22px; box-shadow: var(--lift); }
.bubble {
  width: 46px; height: 46px; border-radius: 15px; flex: none;
  display: grid; place-items: center;
  background: var(--c); color: var(--ink); border: 2px solid var(--ink);
}
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 24px; border-radius: 18px;
  background: var(--orange); color: var(--ink); border: var(--line); box-shadow: 0 5px 0 var(--ink);
  font-weight: 900; font-size: calc(17rem / 17);
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: calc(14rem / 17); font-weight: 800;
  background: var(--card); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-head h2 { font-size: calc(20rem / 17); font-weight: 800; }

/* bấm = lún xuống thật (bóng co lại) */
.press { transition: transform .25s var(--spring), box-shadow .25s var(--spring); }
.press:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* ===== Sticker ảnh chi tiêu ===== */
.polaroid {
  flex: none; margin: 0; width: 104px; padding: 6px 6px 8px; border-radius: 16px; background: var(--card);
  border: var(--line); box-shadow: var(--lift);
}
.polaroid .photo { height: 88px; border-radius: 10px; border: 2px solid var(--ink); display: grid; place-items: center; background: var(--c); color: var(--ink); }
.polaroid .photo svg { width: 40px; height: 40px; }
.polaroid img.photo { width: 100%; object-fit: cover; display: block; }
.polaroid figcaption { margin-top: 6px; font-size: calc(12rem / 17); font-weight: 800; text-align: center; }

/* ===== Motion ===== */
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.96); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(2deg); } }
@keyframes coin {
  0% { transform: translateY(-34px) rotateY(0); opacity: 0; }
  15% { opacity: 1; }
  65% { transform: translateY(4px) rotateY(540deg); opacity: 1; }
  80%, 100% { transform: translateY(8px) rotateY(720deg); opacity: 0; }
}
@keyframes wiggle { 0%, 100% { transform: rotate(var(--t, 0deg)); } 50% { transform: rotate(calc(var(--t, 0deg) * -1)) translateY(-3px); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes grow-y { from { transform: scaleY(0); } }

.rise { animation: rise .7s var(--soft-spring) both; animation-delay: var(--d, 0ms); }
.bob { animation: bob 3s ease-in-out infinite; transform-origin: 50% 90%; }
.coin { animation: coin 2.4s cubic-bezier(.3, 1.3, .5, 1) infinite; }
.wig { animation: wiggle 4s ease-in-out infinite; animation-delay: var(--d, 0s); }

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

/* Tăng tương phản / giảm trong suốt: kính thành nền đặc, viền mực */
@media (prefers-contrast: more), (prefers-reduced-transparency: reduce) {
  .glass { background: var(--card) !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; border: 2px solid var(--ink) !important; }
  .step-camera .glass { background: var(--ink) !important; border-color: #FFF !important; }
}

/* ===== Tab bar Liquid Glass (kiểu iOS 26) ===== */
.glass {
  background: rgba(255, 255, 255, .32);
  backdrop-filter: blur(16px) saturate(1.9);
  -webkit-backdrop-filter: blur(16px) saturate(1.9);
  border: 1px solid rgba(255, 255, 255, .6);
  box-shadow:
    inset 0 1.5px 1px rgba(255, 255, 255, .95),   /* viền sáng trên — specular */
    inset 0 -1px 1px rgba(255, 255, 255, .4),
    inset 0 0 16px rgba(255, 255, 255, .3),
    0 10px 30px rgba(27, 35, 64, .18), 0 1px 3px rgba(27, 35, 64, .12);
}

.tab-bar {
  position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 10;
  margin: 0 auto; max-width: 406px;
  display: flex; align-items: center; gap: 10px;
}
.tab-bar .tabs {
  --idx: 0;
  position: relative; flex: 1; min-width: 0; display: flex; padding: 4px; border-radius: 999px;
}
.tab-bar .lens {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 4);
  border-radius: 999px;
  background: rgba(255, 255, 255, .6);
  box-shadow: inset 0 1px 1px #FFF, inset 0 -1px 2px rgba(27, 35, 64, .08), 0 2px 8px rgba(27, 35, 64, .1);
  transform: translateX(calc(var(--idx) * 100%));
  transition: transform .5s cubic-bezier(.3, 1.35, .5, 1);
}
/* m1/m2 xen kẽ để animation chạy lại mỗi lần đổi tab */
.tab-bar .lens.m1 { animation: squish1 .5s ease-out; }
.tab-bar .lens.m2 { animation: squish2 .5s ease-out; }
@keyframes squish1 { 35% { scale: 1.18 .88; } 70% { scale: .96 1.04; } }
@keyframes squish2 { 35% { scale: 1.18 .88; } 70% { scale: .96 1.04; } }

.tab-bar .tabs a {
  position: relative; flex: 1; min-width: 0; height: 54px; border-radius: 999px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  color: var(--ink); font-size: 10px; font-weight: 700; letter-spacing: .1px; /* nhãn tab giữ cỡ cố định như iOS */
  transition: color .3s, transform .3s var(--spring);
}
.tab-bar .tabs a:active { transform: scale(.9); }
.tab-bar .tabs a[aria-current="page"] { color: var(--orange-ink); font-weight: 900; }
.tab-bar .tabs .i { width: 25px; height: 25px; }

.tab-bar .cam {
  width: 62px; height: 62px; flex: none; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink);
  background: rgba(255, 122, 26, .82);
  transition: transform .3s var(--spring);
}
.tab-bar .cam:active { transform: scale(.9); }
.tab-bar .cam .i { width: 28px; height: 28px; }
