:root {
  --bg: #0f0f12;
  --panel: rgba(20, 20, 26, 0.88);
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --accent: #ff7a3d;
  --accent-2: #ffb26b;
  --user: #2b6cff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif; overflow: hidden; }
button { font: inherit; cursor: pointer; }

#stage { position: relative; height: 100dvh; width: 100%; display: flex; flex-direction: column; }

#avatar { position: absolute; inset: 0; background-size: cover !important; background-position: center !important; background: radial-gradient(circle at 50% 35%, #2a2a33, #0f0f12 70%); }
#avatar video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
#avatar video.on { opacity: 1; }
/* 綠幕人物：去背後畫在 canvas 上，整個人放進畫面、腳貼底 */
#keyCanvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; display: none; }
body.keyed #keyCanvas { display: block; }
body.keyed #avatar video { visibility: hidden; }
body.keyed #avatar { background: radial-gradient(ellipse at 50% 30%, #6b4a33 0%, #3a2a20 45%, #15100d 100%); }
#placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding-bottom: 30vh; }
#placeholder.hidden { display: none; }
.face { width: min(46vw, 260px); aspect-ratio: 1; border-radius: 50%; background: linear-gradient(160deg, #ffd7b0, #f0a875);
  position: relative; box-shadow: 0 20px 60px rgba(255, 122, 61, .25); }
.eye { position: absolute; top: 40%; width: 9%; height: 12%; background: #3b2a20; border-radius: 50%; animation: blink 4s infinite; }
.eye:first-child { left: 30%; } .eye:nth-child(2) { right: 30%; }
.mouth { position: absolute; left: 50%; top: 64%; width: 22%; height: 6%; transform: translateX(-50%); background: #8a3b2a; border-radius: 0 0 40px 40px; transition: height .1s; }
body.talking .mouth { animation: talk .28s infinite alternate; }
body.listening .face { box-shadow: 0 0 0 10px rgba(43, 108, 255, .35), 0 20px 60px rgba(43, 108, 255, .3); }
@keyframes talk { from { height: 4%; } to { height: 14%; border-radius: 40px; } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }

.brand-logo { height: 34px; width: auto; display: block; filter: drop-shadow(0 1px 4px rgba(0,0,0,.45)); }
#topbar { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px; background: linear-gradient(rgba(0,0,0,.55), transparent); font-weight: 700; }
#status { font-weight: 400; font-size: 14px; color: var(--muted); }

#bubbles { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px;
  padding: 0 16px 12px; overflow: hidden; mask-image: linear-gradient(transparent, #000 35%); }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px; font-size: clamp(16px, 2.4vh, 22px); line-height: 1.45; backdrop-filter: blur(6px); }
.bubble.ai { align-self: flex-start; background: rgba(255,255,255,.14); border-bottom-left-radius: 4px; }
.bubble.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.bubble.interim { opacity: .6; }
.bubble.err { background: #7f1d1d; }

#panel { position: relative; z-index: 2; background: var(--panel); backdrop-filter: blur(12px); border-radius: 20px 20px 0 0;
  padding: 14px 16px max(16px, env(safe-area-inset-bottom)); }
#cart { max-height: 22vh; overflow: auto; }
#cart[hidden] { display: none; }
#cartItems:empty::before { content: "購物車是空的，跟我說想吃什麼吧"; color: var(--muted); font-size: 14px; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 16px; }
.line small { color: var(--muted); margin-left: 6px; }
#cartTotal { text-align: right; font-weight: 700; font-size: 18px; color: var(--accent-2); padding-top: 6px; }
#cartTotal:empty { display: none; }

#controls { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
#micBtn { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 14px 20px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 17px; }
#micBtn .dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
body.listening #micBtn { background: var(--user); }
body.listening #micBtn .dot { animation: pulse 1s infinite; }
body.busy #micBtn { opacity: .5; }
@keyframes pulse { 50% { transform: scale(1.6); opacity: .5; } }
#menuBtn { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 14px 16px;
  background: #fff4e3; color: #8a2f1d; font-weight: 800; font-size: 16px; }
#menuBtn[hidden] { display: none; }
#menuBtn .ico { font-size: 18px; }
body.menu-hint #menuBtn { animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 180, 90, .7); } 50% { box-shadow: 0 0 0 10px rgba(255, 180, 90, 0); } }

/* ---------- 懸浮菜單 ---------- */
#menuSheet { position: absolute; inset: 0; z-index: 7; display: flex; align-items: flex-end; background: rgba(20, 12, 6, .35); }
#menuSheet[hidden] { display: none; }
.sheet { width: 100%; height: 84%; display: flex; flex-direction: column; color: #3b2a1c;
  background: linear-gradient(#fbf3e4, #f5e7cf); border-radius: 26px 26px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.35);
  animation: sheetUp .32s cubic-bezier(.2,.9,.3,1); }
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 18px 6px; }
.sheet-head h2 { margin: 0; font-size: 26px; font-weight: 900; color: #7a2412; letter-spacing: .06em; }
.sheet-head p { margin: 2px 0 0; font-size: 13px; color: #8a6b4f; }
#menuClose { border: 0; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #7a2412; font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
#menuTabs { display: flex; gap: 8px; overflow-x: auto; padding: 8px 18px 10px; scrollbar-width: none; }
#menuTabs button { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 15px; background: #fff; color: #7a2412; }
#menuTabs button.on { background: #9b2c16; color: #fff; }
#menuBody { flex: 1; overflow-y: auto; padding: 0 14px 16px; scroll-behavior: smooth; }
.menu-cat { margin-top: 10px; }
.menu-cat h3 { display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 10px; padding: 6px 18px 6px 14px; font-size: 19px; font-weight: 900; color: #fff;
  background: linear-gradient(90deg, #9b2c16, #b84a2a); border-radius: 0 999px 999px 0; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dish { position: relative; background: #fffaf2; border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(122, 60, 20, .12); display: flex; flex-direction: column; }
.dish img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #eedcc0; }
.dish .tag { position: absolute; top: 8px; left: 8px; background: #c0391b; color: #fff; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.dish .info { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.dish .name { font-weight: 800; font-size: 16px; line-height: 1.3; }
.dish .desc { font-size: 12px; color: #8a6b4f; }
.dish .row { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.dish .price { color: #b8261a; font-weight: 900; font-size: 20px; }
.dish .price small { font-size: 12px; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 32px; height: 32px; border-radius: 50%; border: 0; font-size: 20px; font-weight: 800; line-height: 1; padding: 0; }
.qty .plus { background: #9b2c16; color: #fff; }
.qty .minus { background: #f1dfc4; color: #7a2412; }
.qty b { min-width: 16px; text-align: center; font-size: 16px; }
.dish.picked { box-shadow: 0 0 0 3px #d9822b, 0 2px 10px rgba(122, 60, 20, .2); }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px max(14px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #f0dcc0; }
.sheet-foot small { display: block; color: #8a6b4f; font-size: 13px; }
.sheet-foot b { font-size: 24px; color: #b8261a; }
#menuCheckout { border: 0; border-radius: 999px; padding: 14px 22px; font-size: 17px; font-weight: 900; color: #fff; background: linear-gradient(135deg, #c0391b, #e0702f); box-shadow: 0 6px 18px rgba(192, 57, 27, .35); }
#menuCheckout:disabled { opacity: .45; box-shadow: none; }
@media (min-width: 900px) { .sheet { width: min(960px, 92vw); margin: 0 auto; height: 86%; } .menu-grid { grid-template-columns: repeat(4, 1fr); } }

#textForm { flex: 1; display: flex; min-width: 0; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; }
#textForm input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); padding: 12px 14px; font-size: 16px; outline: none; }
#textForm button { border: 0; background: transparent; color: var(--accent-2); padding: 0 14px; font-weight: 700; }

#startScreen { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: rgba(10,10,14,.6); backdrop-filter: blur(3px); text-align: center; padding: 16px; }
#startScreen.hidden { display: none; }
#startScreen h1 { margin: 0; font-size: clamp(28px, 5vh, 48px); }
#startBtn { border: 0; border-radius: 999px; padding: 20px 44px; font-size: clamp(20px, 3vh, 28px); font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), #ff4d6d); box-shadow: 0 12px 40px rgba(255, 77, 109, .4); animation: breathe 2.4s infinite; }
@keyframes breathe { 50% { transform: scale(1.05); } }
.hint { color: var(--muted); margin: 0; }

/* 取餐號碼放在下方，不擋住數字人鞠躬 */
#orderDone { position: absolute; inset: 0; z-index: 6; display: grid; place-items: end center; background: linear-gradient(transparent 55%, rgba(0,0,0,.55));
  padding: 16px 16px max(24px, env(safe-area-inset-bottom)); }
#orderDone[hidden] { display: none; }
#orderDone .card { background: #fff; color: #111; border-radius: 24px; padding: 28px 32px; text-align: center; min-width: min(90vw, 340px); }
#orderDone .no { font-size: 22px; margin: 8px 0 14px; }
#orderDone .no b { display: block; font-size: 72px; color: var(--accent); line-height: 1.1; }
#orderSummary { color: #555; font-size: 15px; }
#micBtn[hidden] { display: none; }
