:root {
  --red: #d8281e; --red-d: #8f140e; --gold: #ffcf5a; --cream: #fff5e0; --ink: #23160e; --green: #3fbf5a;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --edge: 0px;
}
body.touch { --edge: 28px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #15100c; color: var(--cream);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  /* 整個視窗都不能反白、長按不跳選單 */
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: none;
}
body { position: fixed; inset: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
a { -webkit-user-drag: none; }

/* 左右邊緣的觸控死區 */
.edge-guard { position: absolute; top: 0; bottom: 0; width: var(--edge); z-index: 30; }
.edge-guard.left { left: 0; } .edge-guard.right { right: 0; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: none; }
#ticket {
  position: absolute; left: calc(18px + var(--edge) + var(--sal)); top: calc(14px + var(--sat));
  background: var(--cream); color: var(--ink); padding: 8px 14px 10px; border-radius: 4px; min-width: 150px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45); transform: rotate(-2deg); border-top: 5px solid var(--red);
}
.t-no { font-size: 12px; opacity: .65; letter-spacing: .08em; }
.t-name { font-size: 26px; font-weight: 800; line-height: 1.15; }
.t-req { display: flex; gap: 6px; margin-top: 4px; }
.t-req span { font-size: 14px; font-weight: 700; background: var(--ink); color: var(--cream); padding: 2px 8px; border-radius: 3px; }
.t-req { flex-wrap: wrap; max-width: 250px; }
#tSauce { background: var(--red); } #tDip { background: #7a5a12; } #tVeg { background: #2e7a3c; }
.t-req span.hidden { display: none; }
.t-wait { height: 6px; border-radius: 9px; background: rgba(35, 22, 14, .18); margin-top: 7px; overflow: hidden; }
.t-wait i { display: block; height: 100%; background: #3fae58; transform-origin: left; }
.t-wait i.low { background: var(--red); }
#rush { position: absolute; top: calc(70px + var(--sat)); right: calc(18px + var(--edge) + var(--sar)); background: var(--red); color: #fff; font-weight: 900; font-size: 15px;
  padding: 5px 12px; border-radius: 99px; border: 2px solid var(--gold); animation: rush 0.7s ease-in-out infinite alternate; }
@keyframes rush { from { transform: scale(1); } to { transform: scale(1.08); } }
#btnSkip { pointer-events: auto !important; position: absolute; left: 50%; bottom: calc(84px + var(--sab)); transform: translateX(-50%); background: rgba(20, 12, 8, .82);
  border: 2px solid #6fcf80; color: #c9f5d0; font-size: 16px; font-weight: 800; padding: 10px 20px; border-radius: 99px; }
body.touch #btnSkip { bottom: calc(196px + var(--sab)); }
#btnSkip.want { background: #2e9a48; border-color: #eaffea; color: #fff; font-size: 20px; padding: 14px 26px; box-shadow: 0 6px 22px rgba(0, 0, 0, .45); animation: skipPulse 0.6s ease-in-out infinite alternate; }
@keyframes skipPulse { from { filter: brightness(1); } to { filter: brightness(1.28); } }
#dips { position: absolute; left: 50%; bottom: calc(84px + var(--sab)); transform: translateX(-50%); display: flex; gap: 10px; }
#dips button { pointer-events: auto !important; min-width: 78px; padding: 16px 12px; border-radius: 16px; font-size: 18px; font-weight: 900; color: var(--ink);
  background: var(--cream); border: 3px solid var(--gold); box-shadow: 0 5px 0 rgba(0, 0, 0, .45); }
#dips button:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .45); }
#btnChop.full { border-color: #fff; box-shadow: 0 8px 0 #6d0d07, 0 0 26px #ffd23c; }

.round {
  pointer-events: auto !important; position: absolute; right: calc(18px + var(--edge) + var(--sar)); top: calc(14px + var(--sat));
  width: 48px; height: 48px; border-radius: 50%; background: rgba(20, 12, 8, .72); border: 2px solid rgba(255, 245, 224, .5);
  font-size: 18px; font-weight: 800;
}
#steps { position: absolute; top: calc(22px + var(--sat)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
#steps i {
  white-space: nowrap; font-style: normal; font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 99px;
  background: rgba(20, 12, 8, .6); color: rgba(255, 245, 224, .55); border: 1px solid rgba(255, 245, 224, .18);
}
#steps i.on { background: var(--gold); color: var(--ink); border-color: var(--gold); }

/* 切件大小：橫條代表整條肉，第一刀在最右邊（跟畫面上的肉同方向） */
#cuts { position: absolute; top: calc(62px + var(--sat)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  background: rgba(20, 12, 8, .78); border: 1px solid rgba(255, 245, 224, .25); border-radius: 12px; padding: 7px 12px; }
#cuts span { font-size: 15px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
#cuts span.over { color: #ff8d77; }
.cuts-bar { display: flex; flex-direction: row-reverse; justify-content: flex-start; width: min(300px, 46vw); height: 18px; border-radius: 5px; overflow: hidden; background: rgba(255, 245, 224, .16); }
.cuts-bar i { flex: 0 0 0; box-sizing: border-box; border-left: 2px solid #1b110b; }
.cuts-bar i.none { display: none; } .cuts-bar i.raw { background: rgba(255, 245, 224, .38); }
.cuts-bar i.ok { background: #45c463; } .cuts-bar i.mid { background: #f0b83a; } .cuts-bar i.off { background: #e8523c; }
.cuts-row { display: grid; grid-template-columns: 42px 1fr; gap: 4px 8px; align-items: center; font-size: 12px; font-weight: 700; margin-top: -3px; }
.cuts-row .cuts-bar { grid-column: 2; width: 100%; height: 12px; background: rgba(35, 22, 14, .15); }
.cuts-row .cuts-bar i { border-left-color: var(--cream); }
.cuts-row em { grid-column: 2; font-style: normal; opacity: .7; }

#hint {
  position: absolute; left: 50%; bottom: calc(26px + var(--sab)); transform: translateX(-50%);
  background: rgba(20, 12, 8, .78); padding: 10px 18px; border-radius: 99px; font-size: 16px; font-weight: 700;
  white-space: nowrap; max-width: calc(100vw - 2 * var(--edge) - 24px); overflow: hidden; text-overflow: ellipsis;
  border: 1px solid rgba(255, 207, 90, .45);
}
#hint:empty { display: none; }

#gauge {
  position: absolute; left: 50%; bottom: calc(82px + var(--sab)); transform: translateX(-50%);
  width: min(420px, calc(100vw - 2 * var(--edge) - 60px)); height: 26px; border-radius: 99px; overflow: hidden;
  background: rgba(20, 12, 8, .8); border: 2px solid rgba(255, 245, 224, .6);
}
#gaugeBand { position: absolute; top: 0; bottom: 0; z-index: 2; background: rgba(63, 191, 90, .5); border-left: 3px solid #b6ffc2; border-right: 3px solid #b6ffc2; }
#gaugeFill { position: absolute; inset: 0; background: linear-gradient(90deg, #5a2a0c, #b0561a); transform-origin: left center; transform: scaleX(0); opacity: .92; }
#gauge span { position: absolute; z-index: 3; left: 12px; top: 2px; font-size: 13px; font-weight: 800; text-shadow: 0 1px 2px #000; }

/* 往內縮的大按鈕：引導手指遠離螢幕邊緣 */
#btnChop {
  pointer-events: auto !important; position: absolute; left: 50%; bottom: calc(84px + var(--sab)); transform: translateX(-50%);
  width: min(62vw, 250px); height: 96px; border-radius: 22px; background: linear-gradient(#ef3a2c, #b3190f);
  border: 3px solid var(--gold); font-size: 38px; font-weight: 900; letter-spacing: .1em; color: #fff;
  box-shadow: 0 8px 0 #6d0d07, 0 12px 24px rgba(0, 0, 0, .5); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
#btnChop small { font-size: 13px; font-weight: 700; letter-spacing: .2em; opacity: .85; margin-top: 6px; }
#btnChop:active { transform: translateX(-50%) translateY(6px); box-shadow: 0 2px 0 #6d0d07, 0 4px 10px rgba(0, 0, 0, .5); }

#floaters b {
  position: absolute; transform: translate(-50%, -50%); font-size: 26px; font-weight: 900; opacity: 0; white-space: nowrap;
  text-shadow: 0 2px 0 #000, 0 0 10px rgba(0, 0, 0, .6);
}
#floaters b.go { animation: pop .65s ease-out forwards; }
#floaters b.perfect { color: var(--gold); font-size: 32px; }
#floaters b.good { color: #b9f3c2; }
#floaters b.bad { color: #ff8d77; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 18% { opacity: 1; transform: translate(-50%, -70%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }

/* ---------- 畫面（選單、設定、評分） ---------- */
.screen { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(16px + var(--sat)) calc(16px + var(--edge)) calc(16px + var(--sab)); }
.screen.dim { background: rgba(10, 6, 4, .72); z-index: 50; }
#loading { background: #15100c; z-index: 60; }
.load-box { text-align: center; }
.load-title { font-size: 40px; font-weight: 900; color: var(--gold); letter-spacing: .12em; }
.load-bar { width: 220px; height: 8px; background: rgba(255, 245, 224, .16); border-radius: 9px; margin: 18px auto 10px; overflow: hidden; }
.load-bar i { display: block; height: 100%; background: var(--red); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
.load-txt { font-size: 14px; opacity: .7; }

#menu { justify-content: space-between; background: linear-gradient(rgba(10, 6, 4, .55), rgba(10, 6, 4, 0) 38%, rgba(10, 6, 4, 0) 55%, rgba(10, 6, 4, .78)); }
.sign {
  margin-top: 3vh; text-align: center; background: var(--red); border: 4px solid var(--gold); border-radius: 10px; padding: 12px 34px 14px;
  box-shadow: 0 0 0 4px var(--red-d), 0 10px 30px rgba(0, 0, 0, .55), 0 0 60px rgba(255, 120, 40, .25);
}
.sign h1 { margin: 2px 0; font-size: clamp(44px, 9vw, 84px); font-weight: 900; letter-spacing: .14em; color: var(--gold); text-shadow: 0 3px 0 var(--red-d), 0 0 22px rgba(255, 220, 120, .55); padding-left: .14em; }
.sign-sub { font-size: 15px; letter-spacing: .3em; font-weight: 700; color: var(--cream); }
.sign-en { font-size: 14px; letter-spacing: .2em; color: var(--cream); opacity: .9; }
.menu-btns { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 7vh; }
.big {
  background: linear-gradient(#ffd96a, #f0a92a); color: var(--ink); font-weight: 900; font-size: 30px; letter-spacing: .3em; padding: 16px 56px 16px 64px;
  border-radius: 16px; box-shadow: 0 7px 0 #9a5d0c, 0 12px 22px rgba(0, 0, 0, .45);
}
.big:active { transform: translateY(5px); box-shadow: 0 2px 0 #9a5d0c; }
.big.small { font-size: 22px; padding: 12px 36px 12px 42px; margin-top: 8px; }
.big:disabled { opacity: .5; }
.ghost { background: rgba(20, 12, 8, .66); border: 2px solid rgba(255, 245, 224, .45); border-radius: 12px; padding: 10px 28px; font-size: 17px; font-weight: 700; min-width: 170px; }
.best { font-size: 14px; opacity: .85; min-height: 20px; }
#menu .best { position: absolute; left: calc(20px + var(--edge) + var(--sal)); bottom: calc(22px + var(--sab)); }
/* 「更多小遊戲」：放在角落，不擋到按鈕與畫面主體 */
.more { color: var(--gold); font-size: 15px; font-weight: 700; text-decoration: none; padding: 9px 16px; border-radius: 99px; background: rgba(20, 12, 8, .7); border: 1px solid rgba(255, 207, 90, .5); }
#menu .more { position: absolute; right: calc(20px + var(--edge) + var(--sar)); bottom: calc(18px + var(--sab)); }
.more.inline { margin-top: 16px; }

.panel {
  background: #2a1a10; border: 2px solid rgba(255, 207, 90, .55); border-radius: 18px; padding: 20px 24px 22px; width: min(380px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  max-height: 100%; overflow: auto; touch-action: pan-y;
}
.panel h2 { margin: 0 0 4px; font-size: 26px; letter-spacing: .3em; padding-left: .3em; color: var(--gold); }
.row { width: 100%; display: flex; align-items: center; justify-content: space-between; font-size: 17px; font-weight: 700; padding: 8px 0; border-bottom: 1px solid rgba(255, 245, 224, .12); }
.row input { width: 26px; height: 26px; accent-color: var(--red); }
.seg { display: flex; border: 2px solid rgba(255, 245, 224, .4); border-radius: 10px; overflow: hidden; }
.seg button { background: transparent; padding: 7px 13px; font-size: 15px; font-weight: 700; }
.seg button.on { background: var(--gold); color: var(--ink); }

#card { background: rgba(10, 6, 4, .55); z-index: 45; }
#brief { background: rgba(10, 6, 4, .4); z-index: 44; }
.b-no { font-size: 13px; opacity: .65; letter-spacing: .08em; }
.b-name { font-size: 30px; font-weight: 900; line-height: 1.1; }
.b-pieces { font-size: 24px; font-weight: 800; line-height: 1; }
.b-pieces b { font-size: 68px; font-weight: 900; color: var(--red); margin: 0 4px; }
#brief #next .cuts-bar { width: 100%; height: 14px; background: rgba(35, 22, 14, .15); grid-column: 1 / 4; }
#last { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 10px; border-bottom: 2px dashed rgba(35, 22, 14, .3); }
#last.hidden, #next.hidden { display: none; }
.last-top { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
#last .stars { letter-spacing: 0; }
#last .stars { font-size: 24px; } #last .total span { font-size: 40px; } #last .quote { min-height: 0; font-size: 15px; }
#cardRush { font-style: normal; background: var(--red); color: #fff; font-weight: 900; font-size: 13px; padding: 3px 9px; border-radius: 99px; }
#cardRush.hidden { display: none; }
#next { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.b-part { width: 100%; display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: 4px 8px; font-size: 20px; font-weight: 800; }
.b-part.hidden { display: none; }
.b-part b { font-size: 38px; font-weight: 900; color: var(--red); line-height: 1; }
.b-part b::before { content: '切 '; font-size: 16px; color: var(--ink); } .b-part b::after { content: ' 件'; font-size: 16px; color: var(--ink); }
.b-part em { font-style: normal; font-size: 12px; background: var(--ink); color: var(--cream); padding: 2px 7px; border-radius: 4px; }
.b-part em.hidden { visibility: hidden; }
.b-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.b-tags span { font-size: 14px; font-weight: 800; background: var(--red); color: #fff; padding: 3px 10px; border-radius: 4px; }
.b-tags span.hidden { display: none; }
#bDip { background: #7a5a12; } #bVeg { background: #2e7a3c; }
#next .cuts-bar i { border-left-color: var(--cream); background: #c9812b; }
.t-wait { grid-column: 1 / 3; }
.b-tip { font-size: 15px; font-weight: 700; opacity: .8; }
.receipt { background: var(--cream); color: var(--ink); border: 0; border-top: 8px solid var(--red); border-radius: 6px; animation: drop .32s cubic-bezier(.2, 1.3, .5, 1); }
@keyframes drop { from { transform: translateY(-40px) rotate(-3deg); opacity: 0; } to { transform: none; opacity: 1; } }
.stars { font-size: 34px; color: #e8a013; letter-spacing: .08em; line-height: 1; }
.total { font-weight: 900; line-height: 1; }
.total span { font-size: 64px; } .total small { font-size: 18px; margin-left: 4px; }
.quote { font-size: 16px; font-weight: 700; text-align: center; min-height: 44px; display: flex; align-items: center; }
.bars { width: 100%; display: flex; flex-direction: column; gap: 7px; }
.bar { display: grid; grid-template-columns: 42px 1fr 52px; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.bar div { height: 12px; background: rgba(35, 22, 14, .15); border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--red); transform-origin: left; transform: scaleX(0); transition: transform .5s .15s; }
.bar em { font-style: normal; text-align: right; font-variant-numeric: tabular-nums; opacity: .75; }
.rank { font-size: 30px; font-weight: 900; color: var(--cream); }
#final .total span { color: var(--gold); }
.list { display: flex; gap: 8px; }
.list span { background: rgba(255, 245, 224, .1); border-radius: 8px; padding: 6px 10px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- 手機直向：單獨一套排版 ---------- */
@media (max-aspect-ratio: 85/100) {
  #ticket { left: calc(8px + var(--edge) + var(--sal)); top: calc(10px + var(--sat)); transform: rotate(-1.5deg); display: grid; grid-template-columns: auto auto; column-gap: 12px; align-items: center; padding: 6px 12px 8px; min-width: 0; white-space: nowrap; }
  .t-no { grid-column: 1 / 3; font-size: 11px; }
  .t-name { font-size: 21px; }
  .t-req span { font-size: 13px; padding: 2px 6px; }
  .t-req { margin-top: 0; }
  .round { top: calc(12px + var(--sat)); right: calc(8px + var(--edge) + var(--sar)); width: 44px; height: 44px; }
  #steps { top: calc(84px + var(--sat)); }
  #cuts { top: calc(132px + var(--sat)); }
  #steps { top: calc(96px + var(--sat)); gap: 4px; }
  #steps i { padding: 4px 7px; }
  #rush { top: calc(62px + var(--sat)); right: calc(8px + var(--edge) + var(--sar)); font-size: 13px; }
  #dips { gap: 6px; } #dips button { min-width: 0; padding: 14px 10px; font-size: 16px; }
  .cuts-bar { width: min(300px, 56vw); }
  #steps i { font-size: 12px; padding: 4px 9px; }
  #hint { font-size: 14px; padding: 8px 14px; white-space: normal; text-align: center; width: max-content; bottom: calc(20px + var(--sab)); }
  #gauge { bottom: calc(86px + var(--sab)); }
  .sign { padding: 10px 22px 12px; margin-top: 5vh; }
  .menu-btns { margin-bottom: 11vh; }
  #menu .best { left: 50%; transform: translateX(-50%); bottom: calc(64px + var(--sab)); white-space: nowrap; }
  #menu .more { right: auto; left: 50%; transform: translateX(-50%); }
}
/* 矮的橫向視窗（手機橫拿） */
@media (max-height: 460px) {
  .sign h1 { font-size: 40px; } .sign { margin-top: 0; padding: 6px 22px 8px; }
  .menu-btns { flex-direction: row; margin-bottom: 2vh; }
  .big { font-size: 22px; padding: 10px 34px 10px 40px; }
  .panel { padding: 12px 18px; gap: 6px; }
  .total span { font-size: 40px; } .stars { font-size: 24px; } .quote { min-height: 0; }
  #btnChop { left: auto; right: calc(40px + var(--edge) + var(--sar)); bottom: calc(30px + var(--sab)); transform: none; width: 150px; height: 84px; }
  #btnChop:active { transform: translateY(6px); }
  #steps { display: none; }
  #cuts { top: calc(12px + var(--sat)); }
  body.touch #btnSkip { left: calc(40px + var(--edge) + var(--sal)); bottom: calc(30px + var(--sab)); transform: none; }
  #last .bars { display: none; }
}
