:root {
  --bg: #fff6e0;
  --wood: #b9773f;
  --wood-dark: #8a5228;
  --paper: #fffdf6;
  --ink: #3b2a1a;
  --muted: #9a8466;
  --yellow: #f6c945;
  --green: #6fae3c;
  --red: #e2574c;
  --ok: #5cb85c;
  --warn: #f0ad4e;
  --bad: #e2574c;
  --radius: 14px;
  --shadow: 0 3px 0 rgba(0,0,0,.15);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #f3d98e; color: var(--ink);
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
body { display: flex; justify-content: center; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }

#app { width: 100%; max-width: 480px; height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); position: relative; overflow: hidden; user-select: none; }

#hud { display: flex; gap: 6px; align-items: center; padding: 8px 10px; background: var(--wood-dark); color: #fff;
  font-weight: 800; font-size: 14px; padding-top: max(8px, env(safe-area-inset-top)); }
.hud-item { background: rgba(255,255,255,.14); padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
#hud-money { flex: 1; text-align: center; }
.icon-btn { font-size: 18px; padding: 2px 4px; }

#scene { position: relative; flex: 0 0 auto; height: 47%; min-height: 300px;
  background: linear-gradient(#bfe6ff 0 38%, #e8d7b0 38% 100%); overflow: hidden; }
#awning { position: absolute; inset: 0 0 auto 0; height: 34px;
  background: repeating-linear-gradient(90deg, var(--red) 0 30px, #fff 30px 60px);
  border-radius: 0 0 50% 50% / 0 0 18px 18px; box-shadow: 0 4px 0 rgba(0,0,0,.12); z-index: 2; }
#weather-badge { position: absolute; right: 8px; top: 40px; background: rgba(255,255,255,.85); padding: 3px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 800; z-index: 3; }
#queue { position: absolute; left: 0; right: 0; bottom: 98px; height: 70px; }
.cust { position: absolute; bottom: 0; font-size: 46px; transition: left .5s ease, transform .3s;
  left: calc(8px + var(--i) * 60px); transform: scale(.8); filter: drop-shadow(0 3px 0 rgba(0,0,0,.15)); }
.cust.front { left: calc(50% - 30px); transform: scale(1.15); animation: bob 1.4s ease-in-out infinite; }
.cust:not(.front) { left: calc(50% + 40px + (var(--i) - 1) * 46px); }
.cust.angry { animation: shake .3s linear infinite; }
.empty-q { position: absolute; bottom: 14px; width: 100%; text-align: center; color: var(--muted); font-weight: 700; }
@keyframes bob { 50% { transform: scale(1.15) translateY(-4px); } }
@keyframes shake { 25% { transform: scale(1.1) rotate(-6deg); } 75% { transform: scale(1.1) rotate(6deg); } }

#bubble { position: absolute; left: 10px; right: 10px; top: 42px; background: var(--paper); border-radius: var(--radius);
  padding: 8px 10px 10px; box-shadow: var(--shadow); z-index: 4; border: 2px solid #f1dfb4; }
#bubble::after { content: ""; position: absolute; bottom: -10px; left: calc(50% - 10px); border: 10px solid transparent;
  border-top-color: var(--paper); border-bottom: 0; }
#bubble-text { font-weight: 800; font-size: 15px; line-height: 1.3; }
#bubble-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 12px; background: #fff1c7; border-radius: 999px; padding: 2px 8px; font-weight: 700; white-space: nowrap; }
.chip.price { background: #d8f2c8; margin-left: auto; }
.chip.no { background: #ffd9d4; }
.chip.stage-chip { background: #ffe39a; }
.patience { height: 6px; background: #eee; border-radius: 999px; margin-top: 7px; overflow: hidden; }
#patience-bar { height: 100%; width: 100%; background: var(--ok); transition: width .1s linear; }

#counter { position: absolute; left: 0; right: 0; bottom: 0; height: 98px; z-index: 5;
  background: linear-gradient(var(--wood) 0 12px, var(--wood-dark) 12px 14px, #c98b52 14px);
  display: flex; align-items: center; gap: 8px; padding: 16px 10px 8px; }
#tray { flex: 1; height: 70px; background: #d9e9ef; border-radius: 50px; border: 3px solid #a9c6d0; position: relative;
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
#tray-items { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; padding: 4px 14px; }
.tray-b, .tray-i { display: flex; flex-direction: column; align-items: center; font-size: 24px; line-height: 1; animation: drop .25s ease-out; }
.tray-b small, .tray-i small { font-size: 10px; font-weight: 700; color: var(--ink); margin-top: 2px; white-space: nowrap; }
.tray-i.done { color: var(--green); }
.tray-i.cooking { animation: pulse .6s infinite alternate; }
.cooked-nuong .banana, .cooked-chien .banana { filter: sepia(.8) saturate(1.6) hue-rotate(-15deg) brightness(.85); }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }
@keyframes pulse { to { transform: scale(1.15); } }
#cook-progress { position: absolute; left: 20px; right: 20px; bottom: 4px; height: 5px; background: rgba(0,0,0,.1); border-radius: 9px; overflow: hidden; }
#cook-progress div { height: 100%; width: 0; background: var(--red); }
#tray-actions { display: flex; flex-direction: column; gap: 6px; }

.banana { display: inline-block; position: relative; }
.banana.s0 { filter: hue-rotate(55deg) saturate(1.3) brightness(.95); }
.banana.s2 { filter: saturate(1.2) brightness(.95) sepia(.25); }
.banana.s2::after { content: ""; position: absolute; inset: 20% 15%;
  background: radial-gradient(circle at 30% 40%, #5a3a12 0 7%, transparent 8%), radial-gradient(circle at 60% 60%, #5a3a12 0 6%, transparent 7%),
  radial-gradient(circle at 45% 25%, #5a3a12 0 5%, transparent 6%), radial-gradient(circle at 70% 35%, #5a3a12 0 5%, transparent 6%);
  pointer-events: none; }

.btn { background: #fff; border-radius: 12px; padding: 9px 14px; font-weight: 800; box-shadow: var(--shadow); transition: transform .06s; }
.btn:active, .bbtn:active, .tile:active { transform: translateY(2px); box-shadow: none; }
.btn.primary { background: var(--yellow); }
.btn.ghost { background: rgba(255,255,255,.7); }
.btn.big { font-size: 18px; padding: 13px 18px; width: 100%; }
.btn.small { font-size: 12px; padding: 6px 8px; line-height: 1.25; min-width: 82px; }
.btn[disabled] { opacity: .45; }

#tabs { display: flex; background: var(--wood-dark); }
#tabs button { flex: 1; padding: 10px 4px; color: #f6e2c4; font-weight: 800; font-size: 14px; border-bottom: 3px solid transparent; }
#tabs button.active { color: #fff; border-bottom-color: var(--yellow); background: rgba(255,255,255,.08); }
#panel { flex: 1; overflow-y: auto; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.grid.bananas { display: flex; flex-direction: column; gap: 8px; }
.brow { display: grid; grid-template-columns: 72px repeat(3, 1fr); gap: 6px; align-items: stretch; }
.bname { font-weight: 800; font-size: 13px; align-self: center; }
.bbtn, .tile { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 6px 4px; display: flex; flex-direction: column;
  align-items: center; gap: 1px; font-size: 11px; font-weight: 700; position: relative; }
.bbtn .banana { font-size: 26px; }
.bbtn b, .tile b { position: absolute; top: 3px; right: 6px; font-size: 12px; color: var(--wood-dark); }
.bbtn.empty, .tile.empty { opacity: .4; }
.tile.used { outline: 3px solid var(--green); }
.tile.busy { opacity: .6; }
.grid.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { padding: 10px 4px; text-align: center; font-size: 12px; }
.tile .big { font-size: 30px; }
.tile small { font-size: 10px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; grid-column: 1 / -1; text-align: center; line-height: 1.4; }

#floaters { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.floater { position: absolute; left: 50%; top: 45%; transform: translateX(-50%); font-weight: 900; font-size: 18px; white-space: nowrap;
  padding: 4px 12px; border-radius: 999px; animation: rise 1.6s ease-out forwards; max-width: 94%; overflow: hidden; text-overflow: ellipsis; }
.floater.good { background: #e6ffd8; color: #2e7d18; }
.floater.bad { background: #ffe1dc; color: #b3261e; font-size: 14px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } 15% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -60px); } }
#toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(40,25,10,.9); color: #fff;
  padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; z-index: 30; max-width: 90%; text-align: center; }

#overlay { position: absolute; inset: 0; background: rgba(60,35,10,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#modal { background: var(--paper); width: 100%; max-height: 94%; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 16px 14px;
  padding-bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
#modal h2 { margin: 0; font-size: 20px; }
.title-screen { text-align: center; display: flex; flex-direction: column; gap: 10px; padding: 10px 6px 4px; }
.title-screen .logo { font-size: 90px; animation: bob 2s ease-in-out infinite; }
.title-screen h1 { margin: 0; font-size: 38px; line-height: 1.05; color: var(--wood-dark); text-shadow: 0 3px 0 var(--yellow); }
.title-screen .sub { margin: 0 0 8px; color: var(--muted); font-weight: 700; }
.howto { padding-left: 20px; margin: 0; line-height: 1.5; font-size: 15px; }
.howto li { margin-bottom: 6px; }
.prep-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.money-big { font-weight: 900; font-size: 18px; color: var(--wood-dark); white-space: nowrap; }
.forecast { background: #e9f6ff; border-radius: 12px; padding: 8px 10px; font-size: 14px; line-height: 1.4; }
.notice { background: #fff0d0; border: 1px dashed var(--warn); border-radius: 12px; padding: 8px 10px; font-size: 14px; }
.seg { display: flex; background: #f1e3c4; border-radius: 12px; padding: 3px; }
.seg button { flex: 1; padding: 8px; border-radius: 10px; font-weight: 800; }
.seg button.active { background: #fff; box-shadow: var(--shadow); }
.market, .shop { display: flex; flex-direction: column; gap: 8px; }
.mrow, .urow { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 8px 10px; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.mname, .uinfo { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mname small, .uinfo small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.mbtns { display: flex; gap: 6px; }
.uicon { font-size: 28px; }
.urow.owned { opacity: .6; }
.badge { background: #d8f2c8; color: #2e7d18; font-weight: 800; font-size: 12px; padding: 4px 8px; border-radius: 999px; }
.prep-actions { display: flex; gap: 8px; position: sticky; bottom: -16px; background: var(--paper); padding: 8px 0 4px; }
.prep-actions .btn.ghost { width: auto; }
.grow { flex: 1; }
.report { width: 100%; border-collapse: collapse; font-size: 15px; }
.report td { padding: 6px 4px; border-bottom: 1px dashed #e5d4ae; }
.report td:last-child { text-align: right; font-weight: 800; }
.report .total td { font-size: 18px; border-bottom: 0; }
.report .pos td:last-child { color: #2e7d18; }
.report .neg td:last-child { color: #b3261e; }
.stats { display: flex; justify-content: space-around; font-weight: 700; font-size: 13px; }
.rep-line { text-align: center; font-weight: 800; }
.stars { color: #f0a500; font-size: 20px; letter-spacing: 2px; }
.reviews { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.reviews li { background: #fff; border-radius: 10px; padding: 6px 10px; }

@media (min-width: 481px) { #app { box-shadow: 0 0 40px rgba(0,0,0,.2); } }
@media (max-height: 640px) { #scene { min-height: 270px; } .cust { font-size: 38px; } }
#street { position: absolute; left: 0; right: 0; top: calc(38% - 34px); display: flex; justify-content: space-around;
  font-size: 30px; opacity: .55; filter: saturate(.7); }
#street span:nth-child(3) { animation: ride 9s linear infinite; }
@keyframes ride { from { transform: translateX(-180px); } to { transform: translateX(180px); } }
.tray-b.removable, .tray-i.removable { cursor: pointer; position: relative; }
.tray-b.removable::after, .tray-i.removable::after { content: "−"; position: absolute; top: -4px; right: -6px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--red); color: #fff; font-size: 12px; line-height: 14px; text-align: center; font-weight: 900; }
.tray-tip { position: absolute; top: 2px; left: 0; right: 0; text-align: center; font-size: 9px; color: var(--muted); pointer-events: none; }
#btn-music.off { opacity: .35; }
.reviews li.good { border-left: 4px solid var(--ok); }
.reviews li.bad { border-left: 4px solid var(--bad); }
.rv-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 2px; }
.rv-stars { color: #f0a500; letter-spacing: 1px; }
#event { position: absolute; inset: 0; z-index: 25; background: rgba(40,20,5,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ev-card { background: var(--paper); border-radius: 20px; padding: 16px; width: 100%; max-width: 400px; text-align: center; animation: up .2s ease-out;
  box-shadow: 0 6px 0 rgba(0,0,0,.15); display: flex; flex-direction: column; gap: 8px; }
.ev-card h3 { margin: 0; font-size: 20px; }
.ev-card p { margin: 0; line-height: 1.45; }
.ev-icon { font-size: 48px; }
.ev-good { color: #2e7d18; font-weight: 800; }
.ev-bad { color: #b3261e; font-weight: 800; }
.ev-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.chase-track { position: relative; height: 54px; background: repeating-linear-gradient(90deg, #d8c39a 0 20px, #cdb68a 20px 40px); border-radius: 12px; overflow: hidden; }
.chase-track span { position: absolute; bottom: 6px; font-size: 34px; transition: left .05s linear; transform: scaleX(-1); }
.chase-thief { left: 40%; }
.chase-me { left: 10%; }
.chase-time { height: 6px; background: #eee; border-radius: 9px; overflow: hidden; }
.chase-time div { height: 100%; width: 100%; background: var(--red); }
.chase-btn { font-size: 24px; padding: 18px; animation: pulse .4s infinite alternate; }
.tax-box { background: #fff7e0; border: 2px dashed var(--warn); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.tax-box small { color: var(--muted); }
.tax-box .ev-btns { flex-direction: row; }
.tax-box .ev-btns .btn { flex: 1; }
.cust.leaving { opacity: .55; filter: grayscale(.7); animation: none; }
.seg button { font-size: 13px; padding: 8px 4px; }
.prow { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 12px; padding: 8px 10px; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.pname { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pname small { color: var(--muted); font-size: 12px; }
.pbtn { min-width: 36px; font-size: 18px; padding: 4px 0; }
.pval { min-width: 64px; text-align: center; font-weight: 900; }
.ptag { font-weight: 800; }
.ptag.cheap { color: #2e7d18; }
.ptag.pricey { color: #b3261e; }
.rv-head { align-items: center; gap: 6px; }
.rv-head b { flex: 1; }
.rv-face { font-size: 22px; line-height: 1; }
.rv-text { margin: 2px 0 4px 28px; }
.rv-actions { display: flex; gap: 4px; margin-left: 28px; flex-wrap: wrap; }
.rv-btn { font-size: 11px; font-weight: 700; background: #f4ead2; border-radius: 999px; padding: 3px 8px; }
.rv-reply { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; margin: 4px 0 0 28px; background: #faf5e8; border-radius: 10px; padding: 5px 8px; }
.rv-reply.me { background: #fff1c7; }
.rv-reply .rv-face { font-size: 18px; }
