/* Nông Trại Tri Thức — giao diện bảng gỗ + giấy, viền pixel (box-shadow bốn hướng), font VT323 có đủ dấu tiếng Việt */
:root {
  --px: 3px;
  --bg: #231508; --wood: #7a4a26; --wood2: #a8743c; --wood3: #4e2f18; --paper: #f6ecd0; --paper2: #ecdcb0; --paper3: #e0cc98;
  --ink: #3a2a1a; --muted: #7a6648; --green: #58c04a; --green2: #2e8b3d; --gold: #f2b531; --red: #d8402e; --blue: #3a8fe0; --line: #3a2a1a;
  --pxb: 0 calc(var(--px) * -1) 0 0 var(--line), 0 var(--px) 0 0 var(--line), calc(var(--px) * -1) 0 0 0 var(--line), var(--px) 0 0 0 var(--line);
  --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px);
  font-family: 'VT323', 'Courier New', monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none; font-size: 22px; line-height: 1.1; -webkit-user-select: none; user-select: none; touch-action: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
img { image-rendering: auto; }
#app { position: fixed; inset: 0; overflow: hidden; }
#stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #8fd4f0; touch-action: none; }
#stage canvas { flex: none; display: block; }
#labels, #fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* ---------- nút / khung ---------- */
.ib, .tool, .nb, .btn, .chip { position: relative; background: var(--wood); color: #fff6dc; box-shadow: var(--pxb), inset 0 -4px 0 rgba(0,0,0,.35), inset 0 3px 0 rgba(255,255,255,.18); margin: var(--px); text-shadow: 0 2px 0 rgba(0,0,0,.45); }
.ib { width: 38px; height: 38px; font-size: 24px; display: grid; place-items: center; }
.btn { padding: 6px 12px 8px; font-size: 21px; min-height: 36px; }
.btn.green { background: var(--green2); } .btn.gold { background: #c98a1a; } .btn.red { background: #a8321f; } .btn.blue { background: #2a6ab8; }
.btn:disabled, .btn.off { background: #6a6258; color: #b8ae9c; box-shadow: var(--pxb), inset 0 -4px 0 rgba(0,0,0,.25); cursor: default; text-shadow: none; }
.ib:active, .tool:active, .nb:active, .btn:active:not(:disabled) { transform: translateY(2px); }
:focus-visible { outline: 3px solid #5ad2e6; outline-offset: 2px; }

/* ---------- thanh trên ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: calc(var(--sa-t) + 6px) calc(var(--sa-r) + 8px) 4px calc(var(--sa-l) + 8px); pointer-events: none; }
#hud > * { pointer-events: auto; }
.lvl { color: #fff6dc; width: 46px; height: 46px; flex: none; background: var(--green2); display: grid; place-items: center; align-content: center; }
.lvl .lv-n { font-size: 28px; line-height: .9; } .lvl small { font-size: 13px; opacity: .85; line-height: .8; }
.xp { flex: 1; min-width: 56px; margin: var(--px); }
.xpbar { height: 14px; background: var(--wood3); box-shadow: var(--pxb); position: relative; overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, #7ae060 0 6px, #58c04a 6px 12px); transition: width .6s steps(8); }
.xp small { display: block; font-size: 15px; color: #fff6dc; text-shadow: 0 2px 0 #000, 0 0 3px #000; margin-top: 2px; }
.money, .clock { display: flex; align-items: center; gap: 5px; background: var(--wood3); color: #fff6dc; padding: 4px 8px 5px; margin: var(--px); box-shadow: var(--pxb); font-size: 24px; }
.money b { min-width: 2ch; text-align: right; }
.coin { width: 16px; height: 16px; background: var(--gold); box-shadow: 0 -2px 0 #8a5a10, 0 2px 0 #8a5a10, -2px 0 0 #8a5a10, 2px 0 0 #8a5a10, inset 3px 3px 0 #ffe27a, inset -3px -3px 0 #d8901a; display: inline-block; }
.clock { font-size: 20px; padding: 4px 7px 5px; } .clock span { font-size: 18px; }
@media (max-width: 400px) { .clock span { display: none; } .money { font-size: 22px; } }

#chips { position: absolute; left: calc(var(--sa-l) + 8px); right: calc(var(--sa-r) + 8px); top: calc(var(--sa-t) + 62px); display: flex; gap: 2px; flex-wrap: nowrap; pointer-events: none; }
.chip { display: flex; align-items: center; gap: 5px; padding: 3px 8px 5px; font-size: 20px; pointer-events: auto; background: var(--wood3); }
.chip b { min-width: 1.4ch; } .chip i { font-style: normal; font-size: 15px; opacity: .8; }
.chip { flex: none; } .chip.ev { flex: 1 1 0; min-width: 0; } .chip.ev em { font-style: normal; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.up { background: #2a6a30; }
.chip[hidden] { display: none; } .chip.raid { background: #3a3f5a; } .chip.raid.warn { background: #8a2a22; animation: bob 0.8s steps(2) infinite; }

#tip { position: absolute; left: 50%; transform: translateX(-50%); width: max-content; top: calc(var(--sa-t) + 110px); max-width: min(86vw, 480px); background: var(--paper); color: var(--ink); padding: 6px 12px 8px; margin: var(--px); box-shadow: var(--pxb); font-size: 19px; text-align: center; pointer-events: none; display: none; }
#tip.on { display: block; animation: bob 1.4s steps(2) infinite; }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-3px); } }

/* ---------- camera ---------- */
#side { position: absolute; right: calc(var(--sa-r) + 6px); top: 40%; transform: translateY(-50%); display: flex; flex-direction: column; }

/* ---------- dock ---------- */
#dock { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 calc(var(--sa-r) + 6px) calc(var(--sa-b) + 4px) calc(var(--sa-l) + 6px); display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
#dock > * { pointer-events: auto; }
#toolrow { display: flex; align-items: stretch; gap: 0; min-height: 70px; }
.tool { flex: none; width: 52px; display: grid; place-items: center; align-content: center; font-size: 17px; background: var(--wood3); } .tool span { font-size: 22px; line-height: 1; }
.tool.on { background: var(--green2); }
#seeds { flex: 1; min-width: 0; display: flex; gap: 2px; overflow-x: auto; overflow-y: hidden; padding: 4px 4px 6px; margin: var(--px); background: rgba(35, 21, 8, .78); box-shadow: var(--pxb); scrollbar-width: none; touch-action: pan-x; }
#seeds::-webkit-scrollbar { display: none; }
.seed { flex: none; width: 60px; background: var(--paper2); box-shadow: var(--pxb), inset 0 -3px 0 rgba(0,0,0,.18); margin: var(--px); padding: 2px 0 3px; display: grid; place-items: center; text-align: center; color: var(--ink); font-size: 16px; line-height: 1; position: relative; }
.seed img { width: 32px; height: 32px; } .seed small { font-size: 15px; color: var(--muted); }
.seed.sel { background: #fff3b0; box-shadow: 0 0 0 var(--px) var(--gold), 0 0 0 calc(var(--px) * 2) var(--line), inset 0 -3px 0 rgba(0,0,0,.18); }
.seed.lock { filter: grayscale(1) brightness(.8); opacity: .7; }
.seed.lock::after { content: attr(data-lock); position: absolute; inset: 0; display: grid; place-items: center; background: rgba(30, 20, 10, .62); color: #fff; font-size: 16px; text-align: center; }
.seed.fish { background: #cfe8f6; }
#nav { display: flex; gap: 0; }
.nb { flex: 1; min-width: 0; padding: 5px 0 6px; display: grid; place-items: center; font-size: 16px; line-height: 1; } .nb span { font-size: 24px; line-height: 1.1; }
.badge { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 4px; background: var(--red); color: #fff; font-style: normal; font-size: 16px; line-height: 20px; box-shadow: var(--pxb); display: none; text-align: center; text-shadow: none; }
.badge.on { display: block; }

/* ---------- nhãn trên bản đồ, chữ nổi ---------- */
.lab { position: absolute; transform: translate(-50%, -100%); background: rgba(246, 236, 208, .92); color: var(--ink); padding: 1px 6px 3px; font-size: 17px; white-space: nowrap; box-shadow: var(--pxb); }
.lab.lock { background: rgba(60, 40, 20, .9); color: #ffe9b0; } .lab.dim { opacity: .0; }
.lab.zone { background: rgba(88, 192, 74, .92); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.5); }
.fxt { position: absolute; transform: translate(-50%, -50%); font-size: 26px; color: #fff; text-shadow: 0 2px 0 #000, 2px 0 0 #000, -2px 0 0 #000, 0 -2px 0 #000; white-space: nowrap; animation: rise 1.15s steps(12) forwards; display: flex; align-items: center; gap: 3px; }
.fxt img { width: 26px; height: 26px; } .fxt.gold { color: #ffe27a; } .fxt.red { color: #ff7a6a; } .fxt.blue { color: #8ad0ff; }
@keyframes rise { 0% { opacity: 0; margin-top: 8px; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; margin-top: -46px; } }

/* ---------- thông báo ---------- */
#toasts { position: absolute; left: 0; right: 0; bottom: calc(var(--sa-b) + 168px); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 5; }
.toast { background: var(--paper); color: var(--ink); padding: 5px 12px 7px; margin: var(--px); box-shadow: var(--pxb); font-size: 20px; max-width: 92vw; text-align: center; animation: pop .25s steps(4), fade .4s steps(4) 2.6s forwards; }
.toast.good { background: #d8f2c0; } .toast.bad { background: #f8d0c8; } .toast.lv { background: var(--gold); font-size: 26px; padding: 8px 18px 10px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } } @keyframes fade { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- bảng (sheet) ---------- */
#sheetWrap { position: absolute; inset: 0; display: none; z-index: 10; }
#sheetWrap.on { display: block; }
#sheetBack { position: absolute; inset: 0; background: rgba(20, 12, 4, .55); }
#sheet { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100vw, 560px); max-height: calc(100% - var(--sa-t) - 56px); display: flex; flex-direction: column; background: var(--paper); color: var(--ink); box-shadow: var(--pxb), 0 -6px 0 var(--wood); animation: up .22s steps(5); margin-bottom: 0; border-top: 6px solid var(--wood2); }
@keyframes up { from { transform: translateX(-50%) translateY(40px); opacity: 0; } }
@media (min-width: 720px) { #sheet { bottom: 50%; transform: translate(-50%, 50%); max-height: 86%; animation: none; border: 0; margin: 0; } }
#sheet > header { display: flex; align-items: center; justify-content: space-between; background: var(--wood); color: #fff6dc; padding: 4px 6px 4px 14px; text-shadow: 0 2px 0 rgba(0,0,0,.45); }
#sheet h2 { margin: 0; font-size: 28px; font-weight: 400; }
#sheetTabs { display: flex; gap: 0; padding: 6px 8px 0; background: var(--paper2); overflow-x: auto; scrollbar-width: none; }
#sheetTabs:empty { display: none; }
.tab { flex: none; padding: 4px 12px 5px; font-size: 21px; background: var(--paper3); color: var(--muted); margin: 0 3px 0 0; box-shadow: var(--pxb); } .tab.on { background: var(--paper); color: var(--ink); }
#sheetBody { padding: 10px 10px calc(var(--sa-b) + 14px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-user-select: text; user-select: text; flex: 1; }
.card { display: flex; align-items: center; gap: 10px; background: var(--paper2); margin: 8px 4px; padding: 8px 10px; box-shadow: var(--pxb); }
.card.lock { opacity: .72; } .card.hl { background: #fff3b0; } .card.done { background: #d8f2c0; }
.card img.ico { width: 44px; height: 44px; flex: none; }
.card .meta { flex: 1; min-width: 0; } .card .meta b { font-size: 24px; font-weight: 400; display: block; } .card .meta small { display: block; font-size: 17px; color: var(--muted); line-height: 1.05; margin-top: 2px; }
.card .act { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.price { font-size: 22px; display: inline-flex; align-items: center; gap: 4px; } .price .coin { width: 13px; height: 13px; }
.up { color: #2a8a30; } .down { color: #b8321f; } .sub { font-size: 17px; color: var(--muted); }
.note { background: #fff3b0; padding: 6px 10px 8px; margin: 6px 4px; box-shadow: var(--pxb); font-size: 19px; line-height: 1.1; }
.note.blue { background: #d8ecfa; } .note.green { background: #d8f2c0; }
.bar { height: 12px; background: var(--paper3); box-shadow: var(--pxb); margin: 5px 3px 3px; overflow: hidden; } .bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, #7ae060 0 6px, #58c04a 6px 12px); }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; } .row.end { justify-content: flex-end; }
.lines { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; } .line { display: inline-flex; align-items: center; gap: 2px; font-size: 20px; } .line img { width: 28px; height: 28px; } .line.miss { color: #b8321f; }
h3 { font-size: 24px; margin: 12px 4px 2px; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 4px; } .stat { background: var(--paper2); margin: 6px 4px; padding: 6px 10px 8px; box-shadow: var(--pxb); } .stat b { display: block; font-size: 28px; font-weight: 400; } .stat small { font-size: 17px; color: var(--muted); }
a { color: #2a6ab8; }
.tiers .btn { padding: 2px 9px 4px; min-height: 30px; font-size: 19px; }
textarea { width: 100%; height: 76px; font: 15px/1.1 monospace; background: #fff; border: 3px solid var(--line); padding: 4px; user-select: text; -webkit-user-select: text; resize: none; }

/* ---------- quiz ---------- */
.q-card { background: #fff; box-shadow: var(--pxb); margin: 8px 4px; padding: 14px 10px 16px; text-align: center; }
.q-word { font-size: 40px; line-height: 1; margin: 2px 0 6px; } .q-hint { font-size: 18px; color: var(--muted); }
.q-text { font-size: 25px; line-height: 1.08; margin: 2px 0 8px; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; } .q-exp { display: block; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.opts { display: grid; gap: 4px; margin: 4px; }
.opt { text-align: left; background: var(--paper2); box-shadow: var(--pxb), inset 0 -4px 0 rgba(0,0,0,.14); margin: 4px 3px; padding: 9px 12px 11px; font-size: 23px; line-height: 1.05; }
.opt:active { transform: translateY(2px); } .opt.ok { background: #8fe070; } .opt.no { background: #f2a090; } .opt[disabled] { cursor: default; }
.rew { display: inline-flex; gap: 10px; font-size: 22px; } .big { font-size: 30px; }

/* ---------- tải trang ---------- */
#splash { position: absolute; inset: 0; background: #1b1f4a; display: grid; place-items: center; z-index: 50; overflow: hidden; transition: opacity .6s steps(6), transform .6s steps(6); }
#splash.off { opacity: 0; transform: scale(1.12); pointer-events: none; }
.sp-box { position: relative; z-index: 3; text-align: center; color: #fff6dc; width: min(80vw, 340px); }
.sp-logo { font-size: 54px; line-height: .95; color: var(--gold); text-shadow: 4px 4px 0 #6a3a10; margin-bottom: 8px; letter-spacing: 2px; }
.sp-logo .ln { display: block; white-space: nowrap; } .sp-logo .l2 { color: #7ae060; text-shadow: 4px 4px 0 #1e5a24; margin-top: .2em; }
.sp-logo b { display: inline-block; font-weight: 400; min-width: .28em; opacity: 0; animation: letterIn .55s steps(6) forwards, letterBob 2.4s steps(2) infinite; animation-delay: calc(var(--i) * 70ms + 400ms), calc(var(--i) * 70ms + 1600ms); }
.sp-sub { font-size: 20px; opacity: 0; text-shadow: 0 2px 0 rgba(0,0,0,.5); margin-bottom: 14px; animation: fadeIn .6s steps(6) 1.5s forwards; }
.sp-track { position: relative; padding-top: 24px; }
.sp-bar { height: 16px; background: #4e2f18; box-shadow: var(--pxb); margin: var(--px); overflow: hidden; } .sp-bar i { display: block; height: 100%; width: 4%; background: repeating-linear-gradient(90deg, #7ae060 0 6px, #58c04a 6px 12px); transition: width .25s steps(6); }
.sp-run { position: absolute; left: 4%; top: 0; width: 0; height: 24px; transition: left .25s steps(6); }
.sp-chick { position: absolute; left: -9px; top: 3px; width: 3px; height: 3px; background: transparent; animation: hop .28s steps(2) infinite;
  box-shadow: 9px 0 0 #e03030, 6px 3px 0 #fffaf0, 9px 3px 0 #fffaf0, 12px 3px 0 #222, 15px 3px 0 #f2a22a, 0 6px 0 #fffaf0, 3px 6px 0 #fffaf0, 6px 6px 0 #fffaf0, 9px 6px 0 #fffaf0, 12px 6px 0 #fffaf0, 3px 9px 0 #f2ecd8, 6px 9px 0 #fffaf0, 9px 9px 0 #fffaf0, 12px 9px 0 #f2ecd8, 6px 12px 0 #f2a22a, 9px 12px 0 #f2a22a; }
#spTxt { font-size: 19px; display: block; margin-top: 4px; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
#spErr { color: #ffb0a0; font-size: 18px; margin-top: 12px; }
/* nền động: bình minh lên trên nông trại */
.sp-sky { position: absolute; inset: 0; background-color: #1b1f4a; animation: dawn 3.2s steps(16) forwards; }
.sp-sky::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(255, 200, 120, .5)); opacity: 0; animation: glow 3.2s steps(16) forwards; }
.sp-sun { position: absolute; left: 50%; top: 24%; width: 48px; height: 48px; margin-left: -24px; background: #ffe27a; box-shadow: 0 0 0 6px rgba(255,226,122,.35), 0 0 0 14px rgba(255,226,122,.18), inset -6px -6px 0 #f2b531; transform: translateY(220px); animation: sunrise 3s steps(15) .2s forwards; }
.sp-cloud { position: absolute; width: 24px; height: 9px; background: #fff; opacity: .9; box-shadow: 12px -9px 0 #fff, 24px 0 0 #fff, 36px -9px 0 #fff, 48px 0 0 #fff; animation: drift 16s linear infinite; }
.sp-cloud.c1 { top: 12%; left: -80px; } .sp-cloud.c2 { top: 22%; left: -80px; animation-duration: 22s; animation-delay: -9s; transform: scale(1.3); } .sp-cloud.c3 { top: 7%; left: -80px; animation-duration: 28s; animation-delay: -18s; opacity: .6; }
.sp-hill { position: absolute; left: 0; right: 0; bottom: 0; }
.sp-hill.h1 { height: 34%; background: #2f7a36; clip-path: polygon(0 45%, 14% 45%, 14% 25%, 32% 25%, 32% 0, 56% 0, 56% 30%, 80% 30%, 80% 12%, 100% 12%, 100% 100%, 0 100%); }
.sp-hill.h2 { height: 22%; background: #58c04a; clip-path: polygon(0 30%, 20% 30%, 20% 10%, 44% 10%, 44% 40%, 70% 40%, 70% 0, 92% 0, 92% 25%, 100% 25%, 100% 100%, 0 100%); }
.sp-field { position: absolute; left: 0; right: 0; bottom: 0; height: 12%; background: repeating-linear-gradient(90deg, #5a3a1f 0 12px, #4e3320 12px 24px); }
.sp-field::before { content: ''; position: absolute; left: 0; right: 0; top: -9px; height: 9px; background: repeating-linear-gradient(90deg, transparent 0 8px, #7ae060 8px 14px, transparent 14px 24px); animation: sway 1.1s steps(2) infinite alternate; }
@keyframes dawn { 0% { background-color: #1b1f4a; } 40% { background-color: #6a4a8a; } 70% { background-color: #f0a060; } 100% { background-color: #8fd4f0; } }
@keyframes glow { 0% { opacity: 0; } 55% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sunrise { to { transform: translateY(0); } }
@keyframes drift { to { transform: translateX(calc(100vw + 200px)); } }
@keyframes sway { to { transform: translateY(-3px); } }
@keyframes hop { 50% { transform: translateY(-3px); } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes letterIn { 0% { opacity: 0; transform: translateY(-46px) scale(1.5); } 70% { opacity: 1; transform: translateY(6px) scale(1); } 100% { opacity: 1; transform: none; } }
@keyframes letterBob { 0%, 100% { transform: none; } 50% { transform: translateY(-3px); } }
/* nhập cảnh vào game: tối viền + màu theo giờ trong ngày */
#vig, #tint { position: absolute; inset: 0; pointer-events: none; }
#vig { background: radial-gradient(ellipse at 50% 45%, transparent 58%, rgba(20, 10, 0, .3) 100%); }
#tint { background: rgba(30, 40, 110, 0); transition: background .8s linear; }
#stage.intro canvas { animation: introIn 1.2s steps(10) both; }
@keyframes introIn { from { opacity: 0; transform: scale(1.08); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #splash *, #splash *::before, #splash *::after, #stage.intro canvas { animation: none !important; } .sp-logo b, .sp-sub { opacity: 1; } .sp-sun { transform: none; } .sp-sky { background-color: #8fd4f0; } }
/* màn rộng: gom HUD / dock vào giữa cho dễ nhìn */
@media (min-width: 820px) {
  #hud, #dock { left: 50%; right: auto; width: 780px; transform: translateX(-50%); }
  #chips { left: 50%; right: auto; width: 780px; transform: translateX(-50%); padding: 0 8px; }
  #toasts { bottom: calc(var(--sa-b) + 190px); }
  .tool { width: 60px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; } }

/* ---------- bong bóng nói (diner.js): mềm, viền nâu mỏng như viền nhân vật ---------- */
#bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bub { position: absolute; left: 0; top: 0; will-change: transform; }
.bub .bb { position: absolute; left: 0; bottom: 12px; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; padding: 4px 9px; background: #fffaf0; border: 2px solid #5a3a22; border-radius: 16px; box-shadow: 0 3px 0 rgba(90, 58, 34, .22), 0 8px 16px rgba(60, 30, 10, .2); white-space: nowrap; animation: bubIn .28s cubic-bezier(.3, 1.6, .5, 1); min-height: 34px; }
.bub .tail { position: absolute; left: -6px; top: -18px; width: 12px; height: 12px; background: #fffaf0; border: 2px solid #5a3a22; border-top: 0; border-left: 0; transform: rotate(45deg); border-radius: 0 0 4px 0; }
.bub img { width: 28px; height: 28px; display: block; }
.bub .ln { display: inline-flex; align-items: center; gap: 1px; font-size: 16px; font-weight: 800; color: #3a2a1a; } .bub .ln.miss { opacity: .55; }
.bub .emo { font-size: 20px; line-height: 1; }
.bub .dots { display: inline-flex; gap: 4px; padding: 0 3px; } .bub .dots i { width: 8px; height: 8px; border-radius: 50%; background: #e0703a; animation: dot 1.1s infinite; } .bub .dots i:nth-child(2) { animation-delay: .18s; } .bub .dots i:nth-child(3) { animation-delay: .36s; }
.bub.ok .bb, .bub.ready .bb { background: #effad8; border-color: #3b7a2a; } .bub.ok .tail, .bub.ready .tail { background: #effad8; border-color: #3b7a2a; }
.bub.ok .bb { animation: bubIn .28s cubic-bezier(.3, 1.6, .5, 1), bubBob 1.1s ease-in-out .3s infinite; }
.bub .chk { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #3fae3a; color: #fff; font-size: 14px; font-weight: 800; }
@keyframes bubIn { from { transform: translateX(-50%) scale(.3); opacity: 0; } }
@keyframes bubBob { 50% { transform: translateX(-50%) translateY(-4px); } }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-4px); opacity: 1; } }

/* =====================================================================================
   Giao diện MỀM (05/11/2026): bo tròn, bóng mờ, chữ tròn Nunito — thay khung gỗ pixel.
   Ghi đè lớp trên bằng biến + vài quy tắc; các lớp cũ vẫn dùng được nên không đụng HTML/JS.
   ===================================================================================== */
:root {
  --px: 0px; --line: #4a3020; font-family: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --pxb: 0 0 0 0 transparent; --sh: 0 2px 0 rgba(58, 34, 14, .32), 0 6px 14px rgba(40, 20, 6, .22); --r: 14px;
  --wood: #8a5a30; --wood2: #b07a42; --wood3: #5a381c; --paper: #fbf3dc; --paper2: #f3e6c2; --paper3: #e8d6a6; --green2: #3a9a3a; --gold: #f5b82e;
}
html, body { font-size: 16px; font-weight: 700; line-height: 1.2; letter-spacing: .1px; }
button, textarea { font-family: inherit; }
.ib, .tool, .nb, .btn, .chip { margin: 3px; border-radius: var(--r); box-shadow: var(--sh), inset 0 2px 0 rgba(255, 255, 255, .22); text-shadow: 0 1px 1px rgba(0, 0, 0, .35); background: linear-gradient(#a06a38, #84552b); }
.ib { width: 42px; height: 42px; font-size: 21px; border-radius: 50%; }
.btn { padding: 7px 14px 8px; font-size: 15px; min-height: 36px; font-weight: 800; }
.btn.green { background: linear-gradient(#4cb84a, #368c36); } .btn.gold { background: linear-gradient(#e8a42a, #c98414); } .btn.red { background: linear-gradient(#cc4a34, #a8321f); } .btn.blue { background: linear-gradient(#3c86d0, #2a62b0); }
.btn:disabled, .btn.off { background: #8c857a; color: #d6cfc0; box-shadow: 0 2px 0 rgba(0, 0, 0, .15); text-shadow: none; }
.ib:active, .tool:active, .nb:active, .btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 rgba(0, 0, 0, 0), inset 0 2px 4px rgba(0, 0, 0, .25); }
:focus-visible { outline: 3px solid #4fc3e8; outline-offset: 2px; border-radius: var(--r); }
#hud { gap: 8px; }
.lvl { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(#58c24a, #2f8a35); border: 3px solid #fff3c8; }
.lvl .lv-n { font-size: 22px; font-weight: 900; } .lvl small { font-size: 9px; font-weight: 800; letter-spacing: .6px; }
.xpbar { height: 14px; background: rgba(60, 36, 16, .75); border-radius: 99px; box-shadow: var(--sh); border: 2px solid rgba(255, 243, 200, .85); }
.xpbar i { background: linear-gradient(#9af070, #58c24a); border-radius: 99px; transition: width .6s ease; }
.xp small { font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); margin-top: 3px; }
.money, .clock { background: rgba(60, 36, 16, .82); border-radius: 99px; box-shadow: var(--sh); font-size: 18px; font-weight: 900; padding: 5px 12px; margin: 3px; }
.clock { font-size: 15px; padding: 5px 11px; } .clock span { font-size: 15px; }
.coin { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3a8, #f5b82e 55%, #c98414); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.chip { background: rgba(60, 36, 16, .82); border-radius: 99px; padding: 4px 11px 5px; font-size: 15px; font-weight: 800; gap: 5px; }
.chip i { font-size: 12px; } .chip.up { background: linear-gradient(#3aa23a, #2a7a30); } .chip.raid { background: rgba(58, 63, 90, .9); } .chip.ev em { font-size: 13px; font-weight: 700; }
#tip { background: rgba(251, 243, 220, .96); border-radius: 16px; box-shadow: var(--sh); font-size: 14px; padding: 8px 14px; }
#seeds { background: rgba(60, 36, 16, .72); border-radius: 18px; box-shadow: var(--sh); padding: 5px 5px 7px; margin: 3px; }
.tool { width: 54px; font-size: 12px; font-weight: 800; background: linear-gradient(#6a4220, #4e2f18); } .tool span { font-size: 22px; } .tool.on { background: linear-gradient(#4cb84a, #2f8a35); }
.seed { width: 62px; border-radius: 14px; background: linear-gradient(#fbf3dc, #efe0b6); box-shadow: 0 2px 0 rgba(58, 34, 14, .3); font-size: 12px; font-weight: 800; padding: 4px 0 5px; margin: 2px; }
.seed img { width: 34px; height: 34px; } .seed small { font-size: 12px; font-weight: 800; }
.seed.sel { background: linear-gradient(#fff6bc, #ffe680); box-shadow: 0 0 0 3px var(--gold), 0 4px 10px rgba(40, 20, 6, .3); }
.seed.lock::after { font-size: 12px; border-radius: 14px; }
#nav { gap: 2px; } .nb { padding: 6px 0 7px; font-size: 12px; font-weight: 800; } .nb span { font-size: 22px; }
.badge { min-width: 20px; height: 20px; line-height: 20px; font-size: 12px; font-weight: 900; border-radius: 99px; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); background: #e24a34; }
.lab { background: rgba(255, 250, 235, .94); border-radius: 99px; padding: 2px 10px 3px; font-size: 13px; font-weight: 800; box-shadow: 0 2px 6px rgba(40, 20, 6, .25); }
.lab.lock { background: rgba(70, 44, 20, .88); } .lab.zone { background: rgba(58, 154, 58, .94); }
.fxt { font-size: 20px; font-weight: 900; text-shadow: 0 2px 3px rgba(0, 0, 0, .55), 0 0 2px #000; } .fxt img { width: 28px; height: 28px; }
.toast { background: rgba(251, 243, 220, .97); border-radius: 16px; box-shadow: var(--sh); font-size: 15px; padding: 7px 14px; font-weight: 800; }
.toast.lv { font-size: 19px; padding: 9px 20px; }
/* bảng */
#sheetBack { background: rgba(30, 18, 6, .5); backdrop-filter: blur(2px); }
#sheet { border: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(30, 16, 4, .4); overflow: hidden; background: var(--paper); }
@media (min-width: 720px) { #sheet { border-radius: 22px; } }
#sheet > header { background: linear-gradient(#a06a38, #84552b); padding: 8px 8px 8px 18px; }
#sheet h2 { font-size: 20px; font-weight: 900; }
#sheetTabs { background: var(--paper2); padding: 8px 10px 0; gap: 4px; }
.tab { border-radius: 12px 12px 0 0; background: var(--paper3); font-size: 14px; font-weight: 800; padding: 6px 13px 7px; box-shadow: none; margin: 0; } .tab.on { background: var(--paper); box-shadow: 0 -2px 6px rgba(58, 34, 14, .12); }
.card { background: linear-gradient(#fbf3dc, #f3e6c2); border-radius: 16px; box-shadow: 0 2px 0 rgba(58, 34, 14, .22); margin: 8px 4px; padding: 9px 12px; }
.card.hl { background: linear-gradient(#fff6bc, #ffeb90); } .card.done { background: linear-gradient(#e4f7cc, #cdeaaa); }
.card img.ico { width: 46px; height: 46px; } .card .meta b { font-size: 16px; font-weight: 900; } .card .meta small { font-size: 12.5px; font-weight: 700; margin-top: 3px; line-height: 1.2; }
.price { font-size: 15px; font-weight: 900; } .price .coin { width: 14px; height: 14px; } .sub { font-size: 12.5px; }
.note { border-radius: 14px; box-shadow: 0 2px 0 rgba(58, 34, 14, .18); font-size: 13.5px; font-weight: 700; padding: 8px 12px; line-height: 1.3; }
.bar { height: 12px; border-radius: 99px; background: var(--paper3); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2); } .bar i { border-radius: 99px; background: linear-gradient(#9af070, #58c24a); }
.line { font-size: 15px; font-weight: 800; } .line img { width: 30px; height: 30px; }
h3 { font-size: 17px; font-weight: 900; }
.stat { border-radius: 16px; background: linear-gradient(#fbf3dc, #f3e6c2); box-shadow: 0 2px 0 rgba(58, 34, 14, .2); } .stat b { font-size: 22px; font-weight: 900; } .stat small { font-size: 12px; }
textarea { border: 2px solid var(--line); border-radius: 12px; font: 600 13px/1.25 ui-monospace, monospace; }
.q-card { border-radius: 18px; box-shadow: 0 2px 0 rgba(58, 34, 14, .2), 0 8px 18px rgba(58, 34, 14, .12); padding: 16px 12px 18px; }
.q-word { font-size: 30px; font-weight: 900; } .q-hint { font-size: 14px; } .q-text { font-size: 18px; line-height: 1.35; font-weight: 700; }
.opt { border-radius: 14px; background: linear-gradient(#fbf3dc, #f0e2b8); box-shadow: 0 2px 0 rgba(58, 34, 14, .28); font-size: 16px; font-weight: 800; line-height: 1.3; padding: 10px 14px 11px; margin: 4px 3px; }
.opt.ok { background: linear-gradient(#b4ef90, #8fe070); } .opt.no { background: linear-gradient(#f8b8a8, #f2a090); }
.rew { font-size: 16px; } .big { font-size: 22px; }
/* màn tải */
#splash { transition: opacity .6s ease, transform .6s ease; }
.sp-logo { font-size: 44px; font-weight: 900; letter-spacing: 1px; text-shadow: 0 4px 0 #6a3a10, 0 8px 14px rgba(0, 0, 0, .35); }
.sp-logo .ln { display: block; } .sp-logo .l2 { text-shadow: 0 4px 0 #1e5a24, 0 8px 14px rgba(0, 0, 0, .35); }
.sp-logo b { font-weight: 900; animation: letterIn .6s cubic-bezier(.3, 1.5, .5, 1) forwards, letterBob 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * 70ms + 400ms), calc(var(--i) * 70ms + 1600ms); }
.sp-sub { font-size: 15px; font-weight: 800; }
.sp-bar { height: 14px; border-radius: 99px; background: rgba(60, 36, 16, .8); box-shadow: var(--sh); } .sp-bar i { background: linear-gradient(#9af070, #58c24a); border-radius: 99px; transition: width .25s ease; }
.sp-run { transition: left .25s ease; } #spTxt { font-size: 14px; font-weight: 700; } #spErr { font-size: 14px; }
.sp-sun { border-radius: 50%; }
.sp-cloud { border-radius: 99px; width: 60px; height: 20px; box-shadow: 18px -10px 0 4px #fff, 40px -4px 0 2px #fff; }
.sp-hill.h1, .sp-hill.h2 { clip-path: none; border-radius: 55% 45% 0 0 / 60% 70% 0 0; } .sp-hill.h1 { background: #3a9a42; height: 36%; left: -10%; right: -10%; } .sp-hill.h2 { background: #62c852; height: 24%; left: -20%; right: 10%; }
.sp-field { background: linear-gradient(#6a4a2a, #4e3320); } .sp-field::before { display: none; }
@keyframes dawn { 0% { background-color: #1b1f4a; } 40% { background-color: #7a5a9a; } 70% { background-color: #f4b070; } 100% { background-color: #9bd8f2; } }
#stage.intro canvas { animation: introIn 1.2s ease both; }

/* =====================================================================================
   Bố cục mới (05/11/2026): vòng cấp ở góc trên-trái màn hình, nút camera gọn ở rìa phải, chợ gộp vào cửa hàng (5 nút), chip mưa.
   ===================================================================================== */
#btnHouse { position: absolute; left: calc(var(--sa-l) + 4px); top: calc(var(--sa-t) + 4px); width: 56px; height: 56px; margin: 0; z-index: 4; box-shadow: 0 3px 10px rgba(30, 16, 4, .4), inset 0 2px 0 rgba(255, 255, 255, .25); }
#btnHouse .lv-n { font-size: 26px; } #btnHouse small { font-size: 9px; }
#hud { padding-left: calc(var(--sa-l) + 66px); padding-top: calc(var(--sa-t) + 10px); }
@media (min-width: 820px) and (max-width: 919px) { #hud { left: 0; right: 0; width: auto; transform: none; } }
@media (min-width: 920px) { #hud { padding-left: calc(var(--sa-l) + 8px); } }
#side { right: calc(var(--sa-r) + 2px); top: 46%; gap: 0; }
#side .ib { width: 34px; height: 34px; font-size: 17px; margin: 2px; background: rgba(60, 36, 16, .6); box-shadow: 0 2px 6px rgba(30, 16, 4, .3), inset 0 1px 0 rgba(255, 255, 255, .2); }
.chip.rain.wet { background: linear-gradient(#3a7fc0, #2a5f9a); animation: none; } .chip.rain em { font-style: normal; font-size: 13px; font-weight: 800; white-space: nowrap; }
.tool { width: 46px; font-size: 11px; } .tool span { font-size: 20px; } .tool.on#toolDig { background: linear-gradient(#cc4a34, #a8321f); }
.seed small { white-space: nowrap; font-size: 11px; }
.seed { width: 58px; }
.card.hl .act .btn.gold { min-width: 0; }
[hidden] { display: none !important; }
/* hạt giống: một ô gọn thay cho dải cuộn (chọn hạt trong 🛒 Cửa hàng) */
#toolrow { min-height: 56px; }
#seeds { flex: 1; min-width: 0; display: flex; padding: 3px; overflow: hidden; touch-action: manipulation; background: rgba(60, 36, 16, .72); }
#seeds .seed { width: 100%; display: flex; align-items: center; gap: 8px; padding: 4px 10px; margin: 0; text-align: left; border-radius: 14px; }
#seeds .seed img { width: 34px; height: 34px; flex: none; }
#seeds .sn { flex: 1; min-width: 0; display: grid; } #seeds .sn b { font-size: 14px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } #seeds .sn small { font-size: 11px; font-weight: 700; color: var(--muted); }
#seeds .sw { font-style: normal; font-size: 16px; color: var(--wood3); }
/* thanh dưới chỉ còn 3 công cụ; bảng chọn hạt khi chạm ô trống */
#toolrow { justify-content: center; min-height: 52px; } .tool { width: 66px; }
.pkgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; }
.pk { display: grid; justify-items: center; gap: 1px; padding: 8px 4px 7px; border-radius: 14px; background: linear-gradient(#fbf3dc, #efe0b6); box-shadow: 0 2px 0 rgba(58, 34, 14, .3); color: var(--ink); text-align: center; }
.pk img { width: 40px; height: 40px; } .pk b { font-size: 14px; font-weight: 900; } .pk small { font-size: 11px; font-weight: 700; color: var(--muted); }
.pk.sel { background: linear-gradient(#fff6bc, #ffe680); box-shadow: 0 0 0 3px var(--gold), 0 3px 8px rgba(40, 20, 6, .25); } .pk.lock { opacity: .55; filter: grayscale(.6); } .pk:active { transform: translateY(2px); }

/* =====================================================================================
   Giao diện kiểu game thật (05/11/2026, đợt 6): màn hình gần như trống — vòng cấp góc trái, xu + nước góc phải,
   cụm nút tròn góc dưới phải (3 công cụ + 🛒). Mọi thứ khác (cửa hàng, chợ, Giếng, bếp, bài tập, nhiệm vụ, phòng thủ,
   vịnh, cài đặt) nằm trong MỘT bảng khung gỗ có thanh thẻ biểu tượng ở trên, giống bảng Shop của Farm Together.
   ===================================================================================== */
:root { --fw: #6b3f1c; --fw2: #e2a867; --plank: #e6c48f; --plank2: #d9b27a; --ink2: #5a4328; }
/* ---- vòng cấp (kèm vòng XP bao quanh) ---- */
#btnHouse { position: absolute; left: calc(var(--sa-l) + 8px); top: calc(var(--sa-t) + 8px); width: 58px; height: 58px; margin: 0; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; z-index: 4;
  background: conic-gradient(#a6f27a calc(var(--xp, 0) * 1%), rgba(46, 28, 12, .72) 0); box-shadow: 0 3px 10px rgba(30, 16, 4, .5), inset 0 0 0 1px rgba(255, 255, 255, .15); }
#btnHouse .lv-core { width: 47px; height: 47px; border-radius: 50%; display: grid; place-content: center; text-align: center; line-height: .9; background: radial-gradient(circle at 35% 28%, #86e664, #2f8a35 72%); border: 2px solid #fff3c8; box-shadow: inset 0 -3px 5px rgba(0, 0, 0, .25); }
#btnHouse .lv-n { font-size: 22px; font-weight: 900; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); } #btnHouse small { font-size: 8px; font-weight: 800; letter-spacing: .6px; opacity: .92; }
/* ---- góc phải trên: xu, nước, giờ ---- */
#hud { left: auto; right: calc(var(--sa-r) + 8px); top: calc(var(--sa-t) + 10px); width: auto; transform: none; padding: 0; flex-direction: column; align-items: flex-end; gap: 4px; }
.pill { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px 0 8px; margin: 0; border-radius: 99px; background: rgba(46, 28, 12, .8); color: #fff6dc; font-weight: 900; font-size: 14px; box-shadow: 0 2px 6px rgba(20, 10, 2, .4), inset 0 1px 0 rgba(255, 255, 255, .14); text-shadow: 0 1px 1px rgba(0, 0, 0, .5); min-width: 74px; justify-content: flex-start; }
.pill b { flex: 1; text-align: right; font-variant-numeric: tabular-nums; } .pill .coin { width: 16px; height: 16px; }
.pill.soft { height: 22px; min-width: 0; padding: 0 9px; gap: 4px; background: rgba(46, 28, 12, .52); font-size: 12px; font-weight: 800; box-shadow: none; } .pill.soft.wet { background: rgba(42, 95, 154, .78); }
.pill i { display: none; }
.dropi { display: inline-block; width: 10px; height: 10px; margin: 0 3px 0 3px; background: #46a8f2; border-radius: 0 50% 50% 50%; transform: rotate(45deg); box-shadow: inset -2px -2px 0 rgba(20, 80, 170, .35); }
.pill.low .dropi { background: #f2a04a; } .pill.low b { color: #ffd9a0; }
/* ---- camera: hai nút xoay nhỏ ở góc trái dưới (chụm 2 ngón / cuộn chuột để phóng) ---- */
#side { left: calc(var(--sa-l) + 8px); right: auto; top: auto; bottom: calc(var(--sa-b) + 10px); transform: none; flex-direction: row; gap: 0; }
#side .ib { width: 36px; height: 36px; font-size: 17px; margin: 2px; background: rgba(46, 28, 12, .55); box-shadow: 0 2px 6px rgba(20, 10, 2, .3), inset 0 1px 0 rgba(255, 255, 255, .18); }
#zoomIn, #zoomOut { display: none; }
/* ---- cụm nút tròn góc phải dưới ---- */
#dock { left: auto; right: calc(var(--sa-r) + 10px); bottom: calc(var(--sa-b) + 10px); width: auto; transform: none; padding: 0; flex-direction: row; align-items: flex-end; gap: 8px; }
#toolrow { min-height: 0; justify-content: flex-end; gap: 6px; align-items: flex-end; }
.tool { position: relative; width: 46px; height: 46px; margin: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; align-content: center; gap: 0; background: linear-gradient(#7a5230, #54351c); box-shadow: 0 3px 8px rgba(20, 10, 2, .45), inset 0 2px 0 rgba(255, 255, 255, .2); font-weight: 800; }
.tool span { font-size: 18px; line-height: 1; } .tool em { font-style: normal; font-size: 9px; font-weight: 900; line-height: 1; margin-top: -2px; letter-spacing: .2px; }
.tool.on { background: linear-gradient(#58c24a, #2f8a35); box-shadow: 0 0 0 2px #fff3c8, 0 3px 8px rgba(20, 10, 2, .45); } .tool.on#toolDig { background: linear-gradient(#d4503a, #a8321f); }
.cnt { position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: #2a6ab8; color: #fff; font-style: normal; font-size: 10px; font-weight: 900; line-height: 17px; text-align: center; display: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); } .cnt.on { display: block; }
.menu-btn { position: relative; width: 64px; height: 64px; margin: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 29px; background: radial-gradient(circle at 35% 28%, #f8cd6a, #d58f22 64%, #a8640f); border: 3px solid #fff3c8; box-shadow: 0 4px 12px rgba(20, 10, 2, .5), inset 0 -4px 6px rgba(120, 60, 0, .35); }
.menu-btn:active { transform: translateY(2px); }
.menu-btn .badge { top: -4px; right: -4px; }
#tip { top: calc(var(--sa-t) + 16px); font-size: 13.5px; max-width: min(calc(100vw - 260px), 480px); } @media (max-width: 560px) { #tip { top: calc(var(--sa-t) + 100px); max-width: 86vw; } }
#toasts { bottom: calc(var(--sa-b) + 92px); }
/* nhãn: bỏ nhãn tên khu; nhãn công trình chỉ hiện khi đã phóng gần */
.lab.zone { display: none; }
/* ---- bảng khung gỗ ---- */
#sheetBack { background: rgba(18, 10, 3, .55); }
#sheet { left: 50%; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(94vw, 720px); height: min(86vh, 640px); max-height: calc(100% - var(--sa-t) - var(--sa-b) - 44px); margin: 14px 0 0; padding: 12px 10px 8px; display: flex; flex-direction: column; overflow: visible; border: 0; border-radius: 20px;
  background: linear-gradient(#c88c4e, #a9692f); box-shadow: 0 0 0 3px var(--fw), 0 0 0 7px var(--fw2), 0 20px 44px rgba(18, 8, 0, .6); animation: sheetIn .2s cubic-bezier(.3, 1.3, .5, 1); }
@keyframes sheetIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.93); } }
@media (min-width: 720px) { #sheet { bottom: auto; transform: translate(-50%, -50%); max-height: calc(100% - 44px); animation: sheetIn .2s cubic-bezier(.3, 1.3, .5, 1); } }
#sheet.pop { height: auto; width: min(92vw, 460px); max-height: min(80vh, 600px); }
#sheet > header { position: relative; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; padding: 0; margin: -28px 0 6px; background: none; pointer-events: none; min-height: 30px; }
#sheet h2 { pointer-events: auto; margin: 0; padding: 5px 20px 6px; font-size: 14px; font-weight: 900; letter-spacing: .6px; text-transform: uppercase; color: #4a2a10; text-shadow: 0 1px 0 rgba(255, 240, 200, .6); background: linear-gradient(#f2c372, #cf8d3a); border-radius: 12px; box-shadow: 0 0 0 3px var(--fw), 0 3px 8px rgba(20, 8, 0, .45); max-width: calc(100% - 52px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sheet .ib.x { pointer-events: auto; width: 34px; height: 34px; margin: -4px -4px 0 0; font-size: 15px; font-weight: 900; background: linear-gradient(#e0583e, #b03520); box-shadow: 0 0 0 3px var(--fw), 0 3px 8px rgba(20, 8, 0, .45); }
/* thanh thẻ biểu tượng */
#menuRail { flex: none; display: flex; gap: 2px; padding: 8px 6px 7px; margin: 0 0 7px; border-radius: 12px; background: linear-gradient(#5b3a22, #432a19); box-shadow: inset 0 3px 8px rgba(0, 0, 0, .5), 0 0 0 2px #8a5a30; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; touch-action: pan-x; justify-content: center; }
#menuRail::-webkit-scrollbar { display: none; } #menuRail.pop, #sheet.pop #menuRail { display: none; }
.rt { position: relative; flex: 1 1 0; min-width: 27px; max-width: 48px; height: 42px; margin: 0; padding: 7px 0 0; display: grid; place-items: start center; font-size: 17px; line-height: 1; color: #fff; background: linear-gradient(#4d607c, #2e3d55); clip-path: polygon(0 0, 100% 0, 100% 80%, 50% 100%, 0 80%); opacity: .88; box-shadow: none; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.rt.on { background: linear-gradient(#f6cb68, #d38c25); opacity: 1; transform: translateY(2px); } .rt:active { filter: brightness(1.15); }
.rt .badge { top: 1px; right: 1px; min-width: 15px; height: 15px; line-height: 15px; font-size: 10px; padding: 0 3px; }
#sheetTabs { flex: none; padding: 0 2px 6px; background: none; gap: 5px; margin: 0; }
.tab { background: linear-gradient(#b98348, #9b6a34); color: #fff1d2; border-radius: 99px; padding: 5px 14px 6px; font-size: 13px; font-weight: 800; text-shadow: 0 1px 1px rgba(0, 0, 0, .4); margin: 0; box-shadow: 0 2px 0 rgba(60, 30, 5, .5); } .tab.on { background: linear-gradient(#fff6dc, #f0dcab); color: #4a2a10; text-shadow: none; box-shadow: 0 2px 0 rgba(60, 30, 5, .5), 0 0 0 2px #f5b82e; }
#sheetBody { flex: 1; min-height: 0; margin: 0; padding: 10px 10px calc(var(--sa-b) * 0 + 12px); border-radius: 12px; background: repeating-linear-gradient(90deg, rgba(120, 70, 20, .07) 0 2px, transparent 2px 52px), linear-gradient(#e8c995, #d9b27a); box-shadow: inset 0 2px 10px rgba(70, 35, 8, .4); }
#sheet.pop #sheetBody { flex: 0 1 auto; }
#sheetFoot { flex: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 5px; padding: 7px 2px 1px; } #sheet.pop #sheetFoot { display: none; }
#sheetFoot .fs { max-width: 100%; padding: 3px 10px 4px; border-radius: 99px; background: rgba(54, 32, 14, .72); color: #fff1d2; font-size: 11.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); } #sheetFoot .fs.wet { background: rgba(42, 95, 154, .85); } #sheetFoot .fs.warn { background: rgba(168, 50, 31, .9); }
/* nội dung trong bảng */
#sheetBody .sub, #sheetBody .card .meta small, #sheetBody .q-hint { color: var(--ink2); }
#sheetBody h3 { color: #4a2a10; }
.card { background: linear-gradient(#fff7e0, #f4e3b8); box-shadow: 0 2px 0 rgba(90, 50, 15, .4); }
.note { box-shadow: 0 2px 0 rgba(90, 50, 15, .3); }
.stat { background: linear-gradient(#fff7e0, #f4e3b8); box-shadow: 0 2px 0 rgba(90, 50, 15, .4); }
/* lưới thẻ hàng (hạt giống, vật nuôi) như bảng Shop */
.gridc { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 9px 8px; padding: 6px 2px 4px; }
.gc { position: relative; display: grid; justify-items: center; align-content: start; gap: 3px; min-width: 0; margin: 0; padding: 9px 3px 6px; border-radius: 12px; color: var(--ink); text-align: center; background: linear-gradient(#fff8e2, #f3e1b2); box-shadow: 0 2px 0 rgba(90, 50, 15, .5); }
.gc img { width: 46px; height: 46px; } .gc b { font-size: 11.5px; font-weight: 900; line-height: 1.1; max-width: 100%; overflow-wrap: anywhere; }
.gc .pr { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px 2px; border-radius: 99px; background: rgba(54, 32, 14, .82); color: #fff6dc; font-size: 11.5px; font-weight: 900; } .gc .pr .coin { width: 11px; height: 11px; }
.gc.sel { box-shadow: 0 0 0 3px #f5b82e, 0 4px 10px rgba(40, 20, 6, .4); } .gc:active { transform: translateY(2px); }
.gc.lock { background: linear-gradient(rgba(96, 64, 32, .45), rgba(96, 64, 32, .35)); } .gc.lock img { filter: brightness(0) opacity(.5); } .gc.lock b { color: rgba(60, 36, 16, .7); } .gc.lock .pr { background: rgba(60, 36, 16, .45); }
.gc .lvt { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 99px; display: grid; place-items: center; background: #8a4ac8; color: #fff; font-size: 11px; font-weight: 900; box-shadow: 0 1px 4px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .3); }
.gc .ok { position: absolute; top: -5px; left: -4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #3fae3a; color: #fff; font-size: 12px; font-weight: 900; box-shadow: 0 1px 3px rgba(0, 0, 0, .45); }
.det { position: sticky; bottom: -2px; z-index: 1; display: flex; gap: 10px; align-items: center; margin: 12px -4px -6px; padding: 9px 11px; border-radius: 12px; background: linear-gradient(#fffaea, #f3e1b2); box-shadow: 0 0 0 2px rgba(90, 50, 15, .35), 0 -6px 12px rgba(90, 50, 15, .18); }
.det img { width: 44px; height: 44px; flex: none; } .det .meta { flex: 1; min-width: 0; } .det b { display: block; font-size: 15px; font-weight: 900; } .det small { display: block; font-size: 12px; line-height: 1.25; color: var(--ink2); font-weight: 700; margin-top: 2px; } .det .act { flex: none; display: grid; justify-items: end; gap: 4px; }
@media (max-width: 400px) { #sheet { padding: 12px 7px 7px; } #sheetBody { padding: 8px 7px 10px; } .gridc { grid-template-columns: repeat(4, 1fr); gap: 8px 6px; } .gc b { font-size: 10.5px; } }
@media (max-height: 460px) { #sheet { height: calc(100% - 40px); margin-top: 10px; } }
@media (prefers-reduced-motion: reduce) { #sheet { animation: none; } }

/* ===== ĐỢT 8 (06/11/2026): kim cương, phân công thợ, lò rèn, thị trấn ===== */
#pillDia .dmd { font-size: 14px; line-height: 1; } #pillDia b { color: #bff0ff; }
.tool .cnt:empty { display: none; }
.dia { display: inline-flex; align-items: center; font-weight: 900; font-size: 15px; color: #1a78a8; }
.stockbar { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; margin: 4px; padding: 5px 10px; border-radius: 12px; background: rgba(58, 34, 14, .1); font-size: 14px; font-weight: 900; }
.need { display: flex; flex-wrap: wrap; gap: 3px 10px; margin-top: 3px; font-size: 13px; font-weight: 900; } .need b { font-weight: 900; }
.nd { display: inline-flex; align-items: center; gap: 3px; color: #2c7a30; } .nd small { display: inline; margin: 0; color: inherit; font-size: 11.5px; opacity: .8; } .nd.no { color: #c0392b; } .nd .coin { width: 12px; height: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; } .seg.wide { margin: 6px 4px; } .seg .btn { min-height: 32px; padding: 5px 12px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.ch { display: inline-flex; flex-direction: column; align-items: center; min-width: 50px; padding: 4px 6px 3px; border-radius: 12px; border: 0; background: #e8d6a6; font-size: 17px; line-height: 1.1; cursor: pointer; font-family: inherit; box-shadow: 0 2px 0 rgba(58, 34, 14, .2); }
.ch em { font-style: normal; font-size: 10.5px; font-weight: 800; color: #6a5238; } .ch.on { background: linear-gradient(#4cb84a, #2f8a35); color: #fff; } .ch.on em { color: #eaffdf; }
.wsel { display: block; width: 100%; margin-top: 6px; padding: 6px 8px; border-radius: 10px; border: 2px solid #c8a868; background: #fffaf0; font: 700 13px/1.2 inherit; color: #3a2a1a; }
.card.wk .meta { min-width: 0; }
.editbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 24px)); padding: 8px 10px 8px 14px; border-radius: 16px; background: rgba(46, 28, 12, .92); color: #fff6dc; font: 800 13px/1.25 inherit; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.editbar[hidden] { display: none; } .editbar .btn { flex: none; min-height: 32px; padding: 5px 14px; font-size: 14px; background: linear-gradient(#4cb84a, #2f8a35); }
@media (max-width: 430px) { .tool { width: 41px; height: 41px; } .tool span { font-size: 16px; } .tool em { font-size: 8px; } #toolrow { gap: 4px; } #dock { gap: 6px; right: calc(var(--sa-r) + 6px); } .menu-btn { width: 58px; height: 58px; font-size: 26px; } #side .ib { width: 32px; height: 32px; margin: 1px; } #side { left: calc(var(--sa-l) + 4px); } }

/* ---- đợt 4 (12/11/2026): thẻ KEM bo tròn viền ấm thay các viên thuốc nâu sẫm (theo tham chiếu Pokopia: thẻ sáng, chữ mực, viền màu theo loại).
        Chỉ đổi nhóm thông tin nổi (xu/nước/giờ, nhãn trên bản đồ, chip, nút camera); khay hạt + dock gỗ giữ nguyên (chữ trắng bên trong). ---- */
:root { --card: rgba(255, 248, 228, .96); --card-line: #e6c88c; --card-ink: #4a3420; }
.pill, .chip:not(.up):not(.raid), .lab:not(.zone) { background: var(--card); color: var(--card-ink); text-shadow: none; box-shadow: 0 2px 6px rgba(40, 20, 6, .22), inset 0 0 0 2px var(--card-line); }
.pill.soft { background: rgba(255, 248, 228, .9); box-shadow: inset 0 0 0 2px var(--card-line); }
.pill.soft.wet { background: #e4f2fc; color: #1f4e7e; box-shadow: inset 0 0 0 2px #86c0ea; }
.pill.low b { color: #b4540c; }
.lab.lock { background: rgba(244, 236, 214, .94); color: #7a6648; box-shadow: 0 2px 6px rgba(40, 20, 6, .18), inset 0 0 0 2px #cdb88a; }
#side .ib { background: var(--card); color: var(--card-ink); text-shadow: none; box-shadow: 0 2px 6px rgba(30, 16, 4, .25), inset 0 0 0 2px var(--card-line); }
