/* ============ Babelisa — giao diện ============
   Bảng màu lấy từ key art: trời xanh ngọc, biển lam, cát vàng nhạt, lá xanh, gỗ nâu ấm.
   Mọi chuyển động chỉ dùng transform + opacity để giữ 60fps trên điện thoại. */
:root {
  --sky: #5ec8f5;
  --sea: #1fa7d6;
  --sand: #efd9a6;
  --leaf: #4caf50;
  --leaf-d: #2e7d32;
  --wood: #a0623a;
  --wood-d: #5a2d0c;
  --orange: #ff7a1a;
  --yellow: #ffd23f;
  --red: #e53935;
  --ink: #2c1b10;
  --paper: #fffaf0;
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.25);
  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font-ui: 'Nunito', system-ui, sans-serif;
  --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: radial-gradient(120% 90% at 50% 0%, #1d6f96 0%, #0d3b57 55%, #061f30 100%);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
svg.ico { width: 100%; height: 100%; display: block; }
img.ico { width: 100%; height: 100%; display: block; object-fit: contain; }
img { -webkit-user-drag: none; }

#app { height: 100dvh; }
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- Màn hình chờ ---------- */
.loading { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: radial-gradient(120% 90% at 50% 0%, #2a9bd0 0%, #0d3b57 70%); transition: opacity 0.45s ease; }
.loading.out { opacity: 0; pointer-events: none; }
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.loading-lisa { height: min(46vh, 380px); width: auto; animation: loadbob 1.4s ease-in-out infinite; filter: drop-shadow(0 16px 16px rgba(0, 0, 0, 0.35)); }
@keyframes loadbob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-14px) rotate(2deg); } }
.loading-dots { display: flex; gap: 10px; }
.loading-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--yellow); animation: dot 1s ease-in-out infinite; }
.loading-dots i:nth-child(2) { animation-delay: 0.15s; }
.loading-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-10px); opacity: 1; } }

/* ---------- Sân khấu dọc (mobile-first, desktop vẫn đẹp) ---------- */
.stage {
  position: relative;
  width: min(100vw, calc(100dvh * 0.58));
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #0d3b57;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.45);
  isolation: isolate;
}

/* ---------- Lớp bối cảnh (ảnh nền phủ kín) ---------- */
.scene-layer { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.scene-layer.dim::after { content: ''; position: absolute; inset: 0; background: rgba(10, 30, 50, 0.4); }
.scene-frame { position: absolute; inset: 0; opacity: 0; transition: opacity 0.9s ease; }
.scene-frame.in { opacity: 1; }
.scene-frame.out { opacity: 0; }
.bg-frame { position: absolute; inset: 0; overflow: hidden; }
/* .bg-inner mô phỏng object-fit: cover, nên các hiệu ứng đặt theo % toạ độ ảnh gốc 1072x1920 */
.bg-inner {
  position: absolute; left: 50%; top: 50%;
  aspect-ratio: 1072 / 1920;
  min-width: 100%; min-height: 100%;
  width: auto; height: auto;
  transform: translate(-50%, -50%) scale(1.06);
  background-size: cover; background-position: center;
  animation: parallax 36s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes parallax { from { transform: translate(-50.8%, -50.6%) scale(1.06); } to { transform: translate(-49.2%, -49.4%) scale(1.08); } }
.bg-fx, .bg-objects, .night-sky { position: absolute; inset: 0; pointer-events: none; }

/* Mây */
.cloud { position: absolute; height: 7%; border-radius: 999px; background: radial-gradient(ellipse at 30% 60%, #fff 0 40%, rgba(255, 255, 255, 0) 70%), radial-gradient(ellipse at 65% 40%, #fff 0 45%, rgba(255, 255, 255, 0) 72%); filter: blur(1px); animation: drift linear infinite; }
@keyframes drift { from { transform: translateX(-30%); } to { transform: translateX(130%); } }
/* Sóng lấp lánh */
.sparkle { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.9); animation: twinkle ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(0.4); } 50% { opacity: 0.95; transform: scale(1); } }
/* Đom đóm */
.firefly { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #e8ff7a; box-shadow: 0 0 10px 3px rgba(220, 255, 120, 0.8); animation: fly ease-in-out infinite alternate; }
@keyframes fly { 0% { transform: translate(0, 0); opacity: 0.2; } 50% { opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)); opacity: 0.3; } }
/* Khói bếp */
.smoke { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); filter: blur(4px); transform: translate(-50%, -50%); animation: smoke 4.4s linear infinite; }
@keyframes smoke { 0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; } 20% { opacity: 0.6; } 100% { transform: translate(10px, -140px) scale(2.2); opacity: 0; } }
/* Đêm */
.night-sky .star { position: absolute; aspect-ratio: 1; border-radius: 50%; background: #fff; animation: twinkle 2.6s ease-in-out infinite; }
.moon { position: absolute; left: 72%; top: 9%; width: 9%; aspect-ratio: 1; border-radius: 50%; background: #fff6c8; box-shadow: 0 0 40px 16px rgba(255, 246, 200, 0.45); }
.evening-sun { position: absolute; left: 12%; top: 40%; width: 16%; aspect-ratio: 1; border-radius: 50%; background: #ffd36b; box-shadow: 0 0 60px 30px rgba(255, 170, 80, 0.5); opacity: 0.9; }
/* Tint thời điểm trong ngày */
.time-tint { position: absolute; inset: 0; pointer-events: none; transition: opacity 1.2s ease; }
.time-morning .time-tint { opacity: 0; }
.time-afternoon .time-tint { background: linear-gradient(180deg, rgba(255, 220, 150, 0.08), rgba(255, 180, 90, 0.18)); }
.time-evening .time-tint { background: linear-gradient(180deg, rgba(120, 60, 160, 0.35), rgba(255, 120, 60, 0.3) 55%, rgba(60, 30, 90, 0.45)); mix-blend-mode: multiply; }
.time-night .time-tint { background: linear-gradient(180deg, rgba(8, 18, 60, 0.72), rgba(10, 25, 70, 0.58)); mix-blend-mode: multiply; }
.time-night .bg-inner::after { content: ''; position: absolute; inset: 0; background: rgba(20, 30, 80, 0.25); }

/* Lửa trại (overlay) */
.campfire { position: absolute; width: 22%; transform: translate(-50%, -85%) scale(var(--s, 1)); }
.campfire svg { width: 100%; display: block; position: relative; z-index: 1; }
.campfire .flames { transform-origin: 60px 100px; animation: flicker 0.32s ease-in-out infinite alternate; }
@keyframes flicker { from { transform: scale(1, 1); } to { transform: scale(1.08, 0.93) rotate(-2deg); } }
.fire-glow { position: absolute; left: 50%; top: 55%; width: 340%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); background: radial-gradient(circle, rgba(255, 160, 60, 0.45) 0%, rgba(255, 160, 60, 0) 65%); animation: glow 1.1s ease-in-out infinite alternate; pointer-events: none; }
@keyframes glow { from { opacity: 0.7; } to { opacity: 1; } }
.ember { position: absolute; left: 44%; top: 40%; width: 5px; height: 5px; border-radius: 50%; background: #ffd23f; animation: ember 2.1s ease-out infinite; z-index: 2; }
@keyframes ember { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(18px, -140px); opacity: 0; } }
.stage.fire-big .campfire { --s: 1.35; }
/* Thủy triều */
.tide { position: absolute; left: 0; right: 0; bottom: 0; height: 60%; transform: translateY(100%); transition: transform 0.4s linear; }
.tide svg { width: 100%; height: 100%; display: block; }
.tide-wave, .tide-foam { animation: tidewave 3s linear infinite; }
@keyframes tidewave { from { transform: translateX(0); } to { transform: translateX(40px); } }
/* Thỏ */
.rabbit { position: absolute; left: -16%; top: 74%; width: 14%; opacity: 0; }
.rabbit.run { animation: rabbitrun 1.6s ease-in-out forwards; }
@keyframes rabbitrun { 0% { transform: translate(0, 0); opacity: 1; } 25% { transform: translate(200%, -30px); } 50% { transform: translate(400%, 0); } 75% { transform: translate(600%, -30px); } 100% { transform: translate(820%, 0); opacity: 1; } }
/* Vẽ trên cát */
.sand-drawing { position: absolute; left: 10%; top: 86%; width: 38%; opacity: 0; transition: opacity 0.8s ease; }
.sand-drawing.show { opacity: 1; }
/* Bia chữ trên tháp (phủ lên ký tự trang trí của ảnh) */
.tower-plaque {
  position: absolute; left: 57.5%; top: 11.5%; width: 15.5%; min-height: 32%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2%;
  padding: 6% 2%;
  background: linear-gradient(180deg, #b8b39a, #8f8a72);
  border-radius: 10px; box-shadow: inset 0 0 0 3px rgba(60, 70, 40, 0.5), inset 0 -8px 0 rgba(0, 0, 0, 0.2), 0 6px 10px rgba(0, 0, 0, 0.3);
  background-image: radial-gradient(circle at 20% 30%, rgba(90, 140, 60, 0.55) 0 10%, transparent 30%), radial-gradient(circle at 80% 70%, rgba(90, 140, 60, 0.5) 0 12%, transparent 32%), linear-gradient(180deg, #b8b39a, #8f8a72);
}
.tower-plaque span { font-family: var(--font-display); font-weight: 700; font-size: clamp(16px, 3.6vmin, 30px); line-height: 1.05; color: #3f4b2e; text-shadow: 0 1px 0 #d7d3bb, 0 -1px 0 #2a301c; }
.tower-plaque.glow span { color: #ffd23f; text-shadow: 0 0 10px rgba(255, 210, 63, 0.9); animation: glow 1.2s ease-in-out infinite alternate; }
.tower-glow { position: absolute; left: 65%; top: 28%; width: 30%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255, 220, 100, 0.6), rgba(255, 220, 100, 0) 65%); animation: glow 1.4s ease-in-out infinite alternate; }

/* ---------- Nhân vật (sprite ảnh) ---------- */
.actors { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.actor {
  position: absolute;
  bottom: 27%;
  height: 42%;
  transform: translateX(-50%) scale(var(--scale, 1));
  transform-origin: 50% 100%;
  transition: left 0.6s ease, bottom 0.6s ease, opacity 0.4s ease, transform 0.6s ease;
  pointer-events: auto;
  filter: drop-shadow(0 14px 10px rgba(0, 0, 0, 0.28));
}
.actor .char-svg { height: 100%; width: auto; display: block; }
.actors.crowded .actor { height: 36%; }
.actors.crowded .actor[data-id='lisa'] { left: 17% !important; }
.actors.crowded .actor[data-id='leo'] { left: 83% !important; }
.actors.crowded .actor[data-id='pablo'] { height: 15%; left: 32% !important; }
.actor.enter { opacity: 0; transform: translateX(-50%) translateY(16px) scale(var(--scale, 1)); }
.actor.leave { opacity: 0; }
.actor.hidden { opacity: 0; }
.actor.far { bottom: 46% !important; left: 26% !important; transform: translateX(-50%) scale(0.42); }
.stage.tall-dock .actors .actor { bottom: 42%; height: 30%; }
.stage.tall-dock .actors .actor.far { bottom: 52% !important; }
.stage.tall-dock .actors .actor[data-id='pablo'] { bottom: 44%; left: 54%; height: 12%; }
.actor[data-id='pablo'] { cursor: pointer; }

.sprite { position: relative; height: 100%; aspect-ratio: 520 / 1200; transform-origin: 50% 100%; animation: breathe 3.6s ease-in-out infinite; animation-delay: var(--breath-delay, 0s); }
.actor[data-id='pablo'] .sprite { aspect-ratio: 760 / 1200; animation-duration: 2.6s; }
@keyframes breathe { 0%, 100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-1.5%) scaleY(1.015); } }
.pose-img { position: absolute; left: 50%; bottom: 0; height: 100%; width: auto; transform: translateX(-50%); opacity: 0; transition: opacity 0.22s ease; }
.pose-img.on { opacity: 1; }
/* nói: nảy nhẹ */
.actor.talking .sprite { animation: talk 0.42s ease-in-out infinite; }
@keyframes talk { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-2.5%) scale(1.01, 0.99); } }
/* vui: nhảy lên */
.actor.jump { animation: jump 0.7s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes jump { 0% { transform: translateX(-50%) scale(var(--scale, 1)); } 35% { transform: translateX(-50%) translateY(-9%) scale(calc(var(--scale, 1) * 1.03)); } 70% { transform: translateX(-50%) translateY(0) scale(calc(var(--scale, 1) * 0.98)); } 100% { transform: translateX(-50%) scale(var(--scale, 1)); } }
/* ngạc nhiên: giật nhẹ */
.actor.shake { animation: shakeChar 0.5s ease; }
@keyframes shakeChar { 0%, 100% { transform: translateX(-50%) scale(var(--scale, 1)); } 25% { transform: translateX(-52%) rotate(-2deg) scale(var(--scale, 1)); } 50% { transform: translateX(-48%) rotate(2deg) scale(var(--scale, 1)); } 75% { transform: translateX(-51%) rotate(-1deg) scale(var(--scale, 1)); } }
.actor.bounce { animation: bounce 0.6s ease; }
@keyframes bounce { 0% { transform: translateX(-50%) scale(var(--scale, 1)); } 40% { transform: translateX(-50%) translateY(-14%) scale(var(--scale, 1)); } 100% { transform: translateX(-50%) scale(var(--scale, 1)); } }
.actor.tilt .sprite { animation: tilt 0.9s ease-in-out; }
@keyframes tilt { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-9deg); } 70% { transform: rotate(6deg); } }
.actor.target::after {
  content: ''; position: absolute; inset: -6% -14%; border-radius: 50%;
  border: 4px dashed var(--yellow); animation: ring 1.2s linear infinite; pointer-events: none;
}
.actor.target.hover::after { border-style: solid; border-color: #fff; background: rgba(255, 210, 63, 0.18); }
@keyframes ring { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ---------- Bong bóng thoại ---------- */
.bubble {
  position: absolute; z-index: 5; top: 68px; max-width: 78%;
  background: #fff; border-radius: 26px; padding: 12px 14px 12px 12px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow);
  font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 6.4vmin, 32px); line-height: 1.15; color: var(--ink);
}
.bubble[data-side='left'] { left: 5%; }
.bubble[data-side='right'] { right: 5%; }
.bubble[data-side='center'] { left: 50%; transform: translateX(-50%); }
.bubble::after { content: ''; position: absolute; bottom: -14px; width: 26px; height: 26px; background: #fff; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.bubble[data-side='left']::after { left: 28px; }
.bubble[data-side='right']::after { right: 28px; }
.bubble[data-side='center']::after { left: calc(50% - 13px); }
.bubble.pop { animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
.bubble[data-side='center'].pop { animation-name: popcenter; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes popcenter { from { transform: translateX(-50%) scale(0.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.bubble-who { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; overflow: hidden; background: #f3f3f3; }
.bubble-text { flex: 1; }
.bubble-text .w { display: inline-block; animation: wordin 0.35s ease backwards; }
@keyframes wordin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.bubble-speak { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; background: var(--sea); color: #fff; padding: 8px; box-shadow: 0 3px 0 #15779b; }
.bubble-speak:active { transform: translateY(2px); box-shadow: none; }

/* ---------- Vật thể Lisa đang cầm ---------- */
.prop {
  position: absolute; z-index: 4; left: 50%; top: 36%; transform: translate(-50%, 0);
  width: clamp(96px, 28vmin, 130px); background: #fff; border-radius: 24px; padding: 10px 10px 6px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: var(--font-display); font-weight: 700; font-size: 20px; cursor: pointer;
}
.prop.pop { animation: propin 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes propin { from { transform: translate(-50%, 20px) scale(0.5); opacity: 0; } to { transform: translate(-50%, 0) scale(1); opacity: 1; } }
.prop-label { color: var(--wood-d); }

/* ---------- HUD ---------- */
.hud { position: absolute; z-index: 8; top: 0; left: 0; right: 0; height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-right { display: flex; gap: 8px; }
.hud-btn { width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, 0.92); color: var(--wood-d); padding: 9px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); position: relative; }
.hud-btn:active { transform: scale(0.94); }
.hud-btn .badge { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--orange); color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hud-title { width: 36px; height: 36px; display: block; color: #fff; }
.day-dots { display: flex; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.5); }
.dot.done { background: var(--leaf); }
.dot.now { background: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.4); }
.planks-mini { display: flex; gap: 3px; background: rgba(0, 0, 0, 0.25); padding: 4px 6px; border-radius: 10px; }
.pm { width: 10px; height: 16px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); }
.pm.on { background: var(--wood); box-shadow: inset 0 -3px 0 var(--wood-d); }
.planks-mini.big .pm { width: 18px; height: 30px; }

/* ---------- Dock (vùng tương tác dưới) ---------- */
.dock {
  position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; min-height: 26%;
  padding: 10px 14px max(14px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px;
  pointer-events: none;
}
.dock > * { pointer-events: auto; }
.btn-next {
  width: 68px; height: 68px; border-radius: 50%;
  background: linear-gradient(180deg, #ffa24d, var(--orange)); color: #fff; padding: 16px;
  box-shadow: 0 6px 0 #c75a0a, 0 12px 24px rgba(0, 0, 0, 0.25); align-self: flex-end;
  animation: nudge 1.6s ease-in-out infinite;
}
.btn-next:active { transform: translateY(4px); box-shadow: 0 2px 0 #c75a0a; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px); } }

.tiles { display: grid; gap: 12px; width: 100%; max-width: 420px; }
.tiles.cols-2 { grid-template-columns: repeat(2, 1fr); }
.tiles.cols-3 { grid-template-columns: repeat(3, 1fr); }
.tiles.small { gap: 8px; }
.tile {
  position: relative; aspect-ratio: 1; background: #fff; border-radius: var(--radius); padding: 12%;
  box-shadow: 0 5px 0 #d9cdb3, 0 10px 20px rgba(0, 0, 0, 0.2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 0.15s ease, opacity 0.3s ease, box-shadow 0.15s ease;
  font-family: var(--font-display); font-weight: 700;
}
.tiles.cols-2 .tile { max-height: 150px; }
.tile.small { padding: 6% 10%; border-radius: 16px; aspect-ratio: 1.45; }
.tile:active { transform: translateY(3px); box-shadow: 0 2px 0 #d9cdb3, 0 6px 12px rgba(0, 0, 0, 0.2); }
.tile .ico { width: 100%; height: auto; flex: 1; min-height: 0; }
.tile-label { font-size: clamp(14px, 4vmin, 20px); color: var(--wood-d); line-height: 1; }
.tile-label.reveal { animation: pop 0.3s ease; }
.tile.ok { background: #e8f8e9; box-shadow: 0 0 0 4px var(--leaf), 0 10px 20px rgba(0, 0, 0, 0.2); transform: scale(1.05); }
.tile.bad { animation: shake 0.45s ease; box-shadow: 0 0 0 4px var(--red), 0 10px 20px rgba(0, 0, 0, 0.2); }
.tile.dim { opacity: 0.3; pointer-events: none; }
.tile.hint { animation: hint 0.9s ease-in-out infinite; }
.tile.selected { box-shadow: 0 0 0 4px var(--yellow), 0 10px 20px rgba(0, 0, 0, 0.2); transform: translateY(-6px); }
.tile.ghost { position: fixed; z-index: 100; width: 96px; pointer-events: none; transform: translate(-50%, -50%) scale(1.1) rotate(-4deg); opacity: 0.95; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes hint { 0%, 100% { box-shadow: 0 5px 0 #d9cdb3, 0 0 0 0 rgba(255, 210, 63, 0.9); } 50% { box-shadow: 0 5px 0 #d9cdb3, 0 0 0 10px rgba(255, 210, 63, 0); } }
.tiles.draggable .tile { touch-action: none; cursor: grab; }

.steps { display: flex; gap: 8px; }
.step { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, 0.6); border: 2px solid #fff; }
.step.done { background: var(--leaf); }
.timer { width: 100%; max-width: 420px; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, 0.35); overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.6); }
.timer-fill { height: 100%; background: linear-gradient(90deg, var(--leaf), var(--yellow), var(--red)); transform-origin: left; transform: scaleX(1); }

.judge { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; max-width: 360px; }
.judge .tile { padding: 14%; }

.speak-dock { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.mic {
  position: relative; width: 96px; height: 96px; border-radius: 50%;
  background: linear-gradient(180deg, #ff6b6b, var(--red)); color: #fff; padding: 24px;
  box-shadow: 0 6px 0 #a32020, 0 12px 24px rgba(0, 0, 0, 0.3); touch-action: none;
}
.mic.on { transform: scale(1.08); box-shadow: 0 2px 0 #a32020, 0 12px 24px rgba(0, 0, 0, 0.3); }
.mic-ring { position: absolute; inset: -8px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.7); opacity: 0; }
.mic.on .mic-ring { animation: micring 1s ease-out infinite; }
@keyframes micring { from { transform: scale(0.9); opacity: 0.9; } to { transform: scale(1.5); opacity: 0; } }
.speak-side { display: flex; gap: 14px; }
.btn-round { width: 54px; height: 54px; border-radius: 50%; background: #fff; color: var(--wood-d); padding: 13px; box-shadow: 0 4px 0 #d9cdb3; }
.btn-round:disabled { opacity: 0.4; }
.btn-round.primary { background: var(--orange); color: #fff; box-shadow: 0 4px 0 #c75a0a; }
.speak-status { width: 40px; height: 40px; }

.stone-read { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.stone-read .tiles.cols-2 .tile { max-height: 120px; }
.stone-tablet {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #a9abb3, #7d7f86);
  border-radius: 18px 18px 26px 26px / 14px 14px 30px 30px; padding: 12px 18px;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 9vmin, 44px); letter-spacing: 4px;
  color: #3b3c44; text-shadow: 0 1px 0 #c9cbd2, 0 -1px 0 #4a4b52;
  box-shadow: inset 0 -6px 0 #5f6168, 0 10px 20px rgba(0, 0, 0, 0.3);
}

/* ---------- Hiệu ứng ---------- */
.fx-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.word-toast {
  position: absolute; left: 50%; top: 20%; transform: translate(-50%, 20px); opacity: 0;
  display: flex; align-items: center; gap: 10px; background: var(--yellow); color: var(--wood-d);
  border-radius: 999px; padding: 8px 18px 8px 8px; font-family: var(--font-display); font-weight: 700; font-size: 22px;
  box-shadow: var(--shadow); transition: transform 0.4s ease, opacity 0.4s ease;
}
.word-toast .ico { width: 40px; height: 40px; }
.word-toast.go { opacity: 1; transform: translate(-50%, 0); }
.float-icon { position: absolute; width: 72px; height: 72px; transform: translate(-50%, -20%); opacity: 0; transition: transform 1s ease, opacity 0.9s ease; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.3)); }
.float-icon.go { opacity: 1; transform: translate(-50%, -110%); }
.float-icon.fade.go { opacity: 0.2; }
.flash { position: absolute; inset: 0; }
.flash.gust { background: repeating-linear-gradient(100deg, transparent 0 40px, rgba(255, 255, 255, 0.35) 40px 46px); animation: gust 1.2s ease-out forwards; }
@keyframes gust { from { transform: translateX(-120%); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }
.flash.splash { background: radial-gradient(ellipse at 50% 100%, rgba(31, 167, 214, 0.9), rgba(31, 167, 214, 0) 70%); animation: splash 1.3s ease-out forwards; }
@keyframes splash { 0% { transform: translateY(60%); opacity: 1; } 60% { transform: translateY(-10%); opacity: 0.9; } 100% { transform: translateY(-30%); opacity: 0; } }
.blackout { position: absolute; inset: 0; background: #06121e; transition: opacity 1.3s ease; }
.blackout.open { opacity: 0; }
.plank-fly { position: absolute; left: 50%; top: 45%; width: 90px; height: 90px; transform: translate(-50%, -50%) scale(1.3); transition: transform 0.9s cubic-bezier(0.4, 0, 0.6, 1), opacity 0.9s; }
.plank-fly.go { transform: translate(140%, 200%) scale(0.3) rotate(40deg); opacity: 0.3; }
.confetti { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px; animation: fall 2s linear forwards; }
@keyframes fall { from { transform: translateY(0) rotate(0); opacity: 1; } to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; } }
/* Sao / lá bay ra từ nhân vật */
.particle { position: absolute; width: 14px; height: 14px; animation: burst 1.1s ease-out forwards; }
.particle.star { background: var(--yellow); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.particle.leaf { background: var(--leaf); border-radius: 0 60% 0 60%; }
@keyframes burst { 0% { transform: translate(-50%, -50%) scale(0.4) rotate(0); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--rot)); opacity: 0; } }
/* Lá rơi khi chuyển cảnh */
.leaf-fall { position: absolute; top: -30px; width: 16px; height: 16px; background: var(--leaf-d); border-radius: 0 70% 0 70%; opacity: 0.9; animation: leaffall linear forwards; }
@keyframes leaffall { 0% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(var(--sway), 28vh) rotate(90deg); } 50% { transform: translate(0, 55vh) rotate(180deg); } 75% { transform: translate(var(--sway), 82vh) rotate(270deg); } 100% { transform: translate(0, 110vh) rotate(360deg); opacity: 0.2; } }

/* ---------- Overlay cuối ngày ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; background: rgba(10, 25, 50, 0.72); display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.dayend { width: 100%; max-width: 420px; background: var(--paper); border-radius: 30px; padding: 22px 18px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: var(--shadow); animation: pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); max-height: 90%; overflow: auto; }
.dayend-stars { display: flex; gap: 4px; color: var(--yellow); }
.dayend-stars .ico { width: 44px; height: 44px; filter: drop-shadow(0 2px 0 #d9a21b); }
.dayend-stars .ico:nth-child(2) { width: 56px; height: 56px; margin-top: -8px; }
.dayend-boat { display: flex; align-items: center; gap: 12px; }
.dayend-boat .ico { width: 80px; height: 80px; }
.dayend-streak { display: flex; gap: 4px; }
.dayend-streak .ico { width: 28px; height: 28px; }
.dayend-words { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.wordcard { position: relative; background: #fff; border-radius: 18px; padding: 10px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--wood-d); box-shadow: 0 4px 0 #e7dcc3; }
.wordcard .ico { width: 54px; height: 54px; }
.wordcard.bounce { animation: cardbounce 0.5s ease; }
@keyframes cardbounce { 50% { transform: translateY(-6px) scale(1.05); } }
.wordcard .box { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: #ddd; }
.box-2 { background: #90caf9 !important; } .box-3 { background: #ffd23f !important; } .box-4 { background: #ff9f1a !important; } .box-5 { background: var(--leaf) !important; }
.btn-big { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 84px; height: 72px; padding: 0 22px; border-radius: 999px; background: linear-gradient(180deg, #ffa24d, var(--orange)); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 24px; box-shadow: 0 7px 0 #c75a0a, 0 14px 28px rgba(0, 0, 0, 0.3); }
.btn-big .ico { width: 36px; height: 36px; }
.btn-big:active { transform: translateY(5px); box-shadow: 0 2px 0 #c75a0a; }
.btn-big.wide { width: 100%; }

/* ---------- Màn hình mở đầu ---------- */
.title-actors { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.title-actors .actor { bottom: 24%; }
.title-bubble { position: absolute; top: 40%; width: 64px; height: 64px; background: #fff; border-radius: 50% 50% 50% 8px; padding: 12px; box-shadow: var(--shadow); font-family: var(--font-display); font-weight: 700; font-size: 38px; display: flex; align-items: center; justify-content: center; color: var(--ink); animation: floaty 3s ease-in-out infinite; }
.title-bubble.left { left: 32%; }
.title-bubble.right { right: 6%; border-radius: 50% 50% 8px 50%; animation-delay: -1.5s; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.title-top { position: absolute; z-index: 3; top: 6%; left: 0; right: 0; text-align: center; padding: 0 20px; }
.logo { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(44px, calc(min(100vw, 100dvh * 0.58) * 0.185), 96px); line-height: 1; letter-spacing: -0.01em; display: flex; justify-content: center; }
.logo span {
  display: inline-block;
  background: linear-gradient(180deg, #ffd27a 0%, #f2a24a 45%, #b8641e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px #5a2d0c;
  filter: drop-shadow(0 5px 0 #5a2d0c) drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35));
  animation: logoIn 0.8s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
}
.logo span:nth-child(odd) { transform: rotate(-4deg) translateY(2px); }
.logo span:nth-child(even) { transform: rotate(3deg) translateY(-3px); }
.logo span:nth-child(n) { animation-delay: calc(var(--i, 0) * 0.06s); }
.logo span:nth-child(2) { --i: 1; } .logo span:nth-child(3) { --i: 2; } .logo span:nth-child(4) { --i: 3; } .logo span:nth-child(5) { --i: 4; } .logo span:nth-child(6) { --i: 5; } .logo span:nth-child(7) { --i: 6; } .logo span:nth-child(8) { --i: 7; }
@keyframes logoIn { from { opacity: 0; transform: translateY(-40px) scale(0.6); } }
.tagline { margin: 14px auto 0; max-width: 300px; color: #fff; font-weight: 800; font-size: 16px; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); }
.title-bottom { position: absolute; z-index: 3; bottom: 5%; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.btn-big.play { width: 96px; height: 96px; padding: 0; border-radius: 50%; animation: pulse 1.8s ease-in-out infinite; }
.btn-big.play .ico { width: 48px; height: 48px; margin-left: 6px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 7px 0 #c75a0a, 0 0 0 0 rgba(255, 122, 26, 0.6); } 50% { box-shadow: 0 7px 0 #c75a0a, 0 0 0 18px rgba(255, 122, 26, 0); } }
.ui-lang { display: flex; gap: 6px; background: rgba(0, 0, 0, 0.3); padding: 4px; border-radius: 999px; }
.ui-lang button { color: #fff; font-weight: 800; font-size: 13px; padding: 6px 12px; border-radius: 999px; opacity: 0.7; }
.ui-lang button.on { background: #fff; color: var(--wood-d); opacity: 1; }

/* ---------- Bảng (setup / settings / notebook) ---------- */
.panel-stage { display: flex; flex-direction: column; }
.panel {
  position: relative; z-index: 2;
  margin: auto 16px; width: calc(100% - 32px); max-height: calc(100% - 90px);
  overflow: auto; background: var(--paper); border-radius: 30px; padding: 22px 20px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.panel-stage .hud + .panel { margin-top: 70px; }
.panel h2 { margin: 0; font-family: var(--font-display); font-size: 24px; color: var(--wood-d); text-align: center; }
.panel-lisa { height: 150px; margin: -90px auto 0; }
.panel-lisa img { height: 100%; width: auto; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.3)); animation: loadbob 3s ease-in-out infinite; }
.lang-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lang-card { position: relative; background: #fff; border-radius: 22px; padding: 18px 12px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 5px 0 #e7dcc3; border: 3px solid transparent; transition: transform 0.15s; }
.lang-card.on { border-color: var(--leaf); background: #f1fbf1; }
.lang-card:active { transform: translateY(3px); }
.lang-name { font-family: var(--font-display); font-weight: 700; font-size: 24px; color: var(--ink); }
.lang-sample { font-family: var(--font-display); font-size: 18px; color: var(--sea); }
.lang-hear { width: 34px; height: 34px; border-radius: 50%; background: var(--sea); color: #fff; padding: 7px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; color: #6b5a44; }
.field input { font: 700 20px var(--font-display); padding: 12px 14px; border-radius: 16px; border: 3px solid #e7dcc3; background: #fff; color: var(--ink); outline: none; }
.field input:focus { border-color: var(--sea); }
.privacy { margin: 0; font-size: 12px; color: #8a7a62; text-align: center; }
.note { margin: 4px 0 0; font-size: 13px; color: #8a4b2a; background: #fff2e4; padding: 8px 10px; border-radius: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 800; font-size: 15px; }
.row.col { flex-direction: column; align-items: stretch; gap: 8px; }
.row.toggle input { position: absolute; opacity: 0; }
.row.toggle i { width: 54px; height: 32px; border-radius: 16px; background: #ccc; position: relative; transition: background 0.2s; flex: 0 0 54px; }
.row.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left 0.2s; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }
.row.toggle input:checked + i { background: var(--leaf); }
.row.toggle input:checked + i::after { left: 25px; }
.radio { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; font-size: 13px; line-height: 1.35; color: #4a3d2e; }
.radio input { margin-top: 3px; accent-color: var(--leaf); }
.radio.disabled { opacity: 0.5; }
.btn-small { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 999px; background: #fff; color: var(--wood-d); font-weight: 800; font-size: 14px; box-shadow: 0 4px 0 #e7dcc3; align-self: flex-start; }
.btn-small .ico { width: 22px; height: 22px; }
.btn-small:active { transform: translateY(3px); box-shadow: none; }
.btn-small.danger { color: var(--red); }
.btn-small.armed { background: var(--red); color: #fff; box-shadow: 0 4px 0 #a32020; }

/* Sổ từ */
.notebook { position: relative; z-index: 2; margin: 70px 12px 12px; max-height: calc(100% - 82px); overflow: auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 20px; }
.nb-day { background: var(--paper); border-radius: 24px; padding: 14px; box-shadow: var(--shadow); }
.nb-day h3 { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 20px; color: var(--wood-d); }
.nb-day h3 .ico { width: 30px; height: 30px; }
.nb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.nb-empty { height: 220px; display: flex; justify-content: center; }
.nb-empty img { height: 100%; width: auto; }

/* ---------- Bản đồ ngày ---------- */
.map-overlay { position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(0, 20, 40, 0.2), rgba(0, 20, 40, 0.4)); }
.map-path { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; }
.map-nodes { position: absolute; inset: 0; z-index: 3; }
.map-node {
  position: absolute; transform: translate(-50%, -50%);
  width: 84px; height: 84px; border-radius: 50%;
  background: #fff; padding: 16px; box-shadow: 0 6px 0 #d9cdb3, 0 12px 24px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}
.map-node:active { transform: translate(-50%, -50%) scale(0.95); }
.map-node.locked { background: #d9d9d9; filter: grayscale(1); opacity: 0.8; }
.map-node.done { background: #e8f8e9; box-shadow: 0 6px 0 #9fd3a4, 0 12px 24px rgba(0, 0, 0, 0.3); }
.map-node.now { animation: nodepulse 1.6s ease-in-out infinite; }
@keyframes nodepulse { 0%, 100% { box-shadow: 0 6px 0 #d9cdb3, 0 0 0 0 rgba(255, 210, 63, 0.9); } 50% { box-shadow: 0 6px 0 #d9cdb3, 0 0 0 16px rgba(255, 210, 63, 0); } }
.node-check, .node-lock { position: absolute; width: 30px; height: 30px; border-radius: 50%; padding: 5px; bottom: -4px; right: -4px; }
.node-check { background: var(--leaf); color: #fff; }
.node-lock { background: #777; color: #fff; }
.node-num { position: absolute; top: -8px; left: -4px; width: 28px; height: 28px; border-radius: 50%; background: var(--wood-d); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.map-lisa { position: absolute; z-index: 3; left: 3%; bottom: 1%; height: 26%; pointer-events: none; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.3)); }
.map-lisa img { height: 100%; width: auto; animation: loadbob 3.2s ease-in-out infinite; }

/* ---------- Giảm chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .bg-inner { animation: none; transform: translate(-50%, -50%); }
  .pose-img { transition: none; }
}
