* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
  color: #4c0519; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; overflow: hidden;
}
#app { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* header */
#hdr { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
#hdr .pill { background: #fffdfd; border: 2px solid #fbcfe0; border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: 14px; min-height: 42px; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
#hdrHome { border: none; background: #e11d48; color: #fff; font-size: 18px; }
#hdrStatus { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hdrMute { cursor: pointer; }

/* screens */
.scr { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding: 6px 14px 20px; }
.scr.on { display: flex; }

/* menu */
#scr-menu { align-items: center; text-align: center; gap: 12px; justify-content: center; }
#scr-menu h1 { font-size: clamp(32px, 9vw, 44px); }
#scr-menu .sub { color: #9f5c72; font-weight: 600; margin-bottom: 4px; }
#tierRow { display: flex; gap: 8px; width: 100%; }
.tierCard { flex: 1; background: #fffdfd; border: 3px solid #fbcfe0; border-radius: 16px; padding: 10px 4px; font-weight: 800; font-size: 14px; line-height: 1.35; cursor: pointer; }
.tierCard small { display: block; color: #9f5c72; font-weight: 700; }
.tierCard .te { font-size: 26px; display: block; }
.tierCard.sel { border-color: #e11d48; background: #ffe4e6; box-shadow: 0 3px 0 #e11d4844; }
button.big { width: 100%; border: none; border-radius: 18px; min-height: 56px; font-size: 20px; font-weight: 800; background: #fffdfd; color: #4c0519; border: 3px solid #fbcfe0; box-shadow: 0 4px 0 #f3aec4; cursor: pointer; }
button.big:active { transform: translateY(3px); box-shadow: 0 1px 0 #f3aec4; }
button.big.primary { background: #e11d48; border-color: #9f1239; color: #fff; box-shadow: 0 4px 0 #9f1239; }
#statsLine { color: #9f5c72; font-weight: 700; }

/* play HUD */
#scr-play { padding: 4px 8px 8px; }
#dinerTop { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px; font-weight: 800; font-size: 15px; }
#dinerTop .hearts { color: #e11d48; letter-spacing: 1px; }
#dinerTop .coins { color: #b45309; }
#dayBar { height: 7px; background: #fbcfe0; border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
#dayFill { height: 100%; width: 0%; background: #e11d48; transition: width 0.3s; }

/* the top-down floor */
#floor {
  flex: 1; position: relative; border-radius: 16px; overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(0,0,0,0.05), transparent 60%),
    repeating-linear-gradient(45deg, #fbe7d3 0 22px, #f6ddc6 22px 44px);
  box-shadow: inset 0 0 0 3px #eaccb0, inset 0 -30px 40px rgba(0,0,0,0.04);
  min-height: 360px;
}
/* kitchen strip along the top */
#kitchen {
  position: absolute; left: 0; right: 0; top: 0; height: 18%;
  background: linear-gradient(#d6e3ea, #b9c9d4);
  border-bottom: 4px solid #8fa3b0; display: flex; align-items: center; justify-content: center; gap: 10px;
}
#kitchen .pass { position: absolute; bottom: 4px; left: 0; right: 0; height: 24px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 20px; }
#kitchen .stove { font-size: clamp(24px, 8vw, 34px); }
#kitchen .klabel { position: absolute; top: 4px; left: 8px; font-size: 11px; font-weight: 800; color: #5b6b76; letter-spacing: 1px; }
/* door at the bottom */
#door { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 34%; height: 8%; background: linear-gradient(#c99b6e, #a97c50); border-radius: 8px 8px 0 0; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #fff3e0; font-weight: 800; }

/* a table (absolutely positioned by JS in %) */
.tbl {
  position: absolute; transform: translate(-50%, -50%);
  width: var(--tsz); height: var(--tsz);
  background: radial-gradient(circle at 40% 30%, #ffffff, #f2d9c4 80%);
  border: 3px solid #d9b892; border-radius: 16px;
  box-shadow: 0 6px 10px rgba(0,0,0,0.18); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.tbl.empty { background: radial-gradient(circle at 40% 30%, #fbeee1, #ecd6c1 80%); box-shadow: 0 3px 6px rgba(0,0,0,0.1); }
.tbl.ready { border-color: #16a34a; box-shadow: 0 0 0 3px #16a34a66, 0 6px 10px rgba(0,0,0,0.18); }
.tbl.cooking { border-color: #f59e0b; }
.tbl.angry { animation: shake 0.4s ease; }
.tbl .plate { font-size: calc(var(--tsz) * 0.5); opacity: 0.5; }

/* a seated customer, sitting just above their table */
.guest { position: absolute; transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 3; }
.guest .face { font-size: var(--gsz); line-height: 1; filter: drop-shadow(0 2px 1px rgba(0,0,0,0.2)); }
.guest .bubble {
  position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, 4px);
  background: #fff; border: 2px solid #e5b9c8; border-radius: 10px; padding: 1px 5px; font-size: calc(var(--gsz) * 0.62); white-space: nowrap;
}
.guest .bubble.cook { filter: none; }
.guest .pat { width: calc(var(--gsz) * 1.3); height: 6px; background: #f3d3dd; border-radius: 999px; overflow: hidden; margin: 2px auto 0; }
.guest .pat > span { display: block; height: 100%; background: #16a34a; }
.guest .pat.warn > span { background: #f59e0b; }
.guest .pat.crit > span { background: #dc2626; }

/* the waiter */
#waiter { position: absolute; transform: translate(-50%, -50%); z-index: 5; text-align: center; pointer-events: none; transition: none; }
#waiter .body { font-size: clamp(30px, 10vw, 40px); line-height: 1; filter: drop-shadow(0 3px 2px rgba(0,0,0,0.25)); }
#waiter .tray { position: absolute; bottom: 78%; left: 50%; transform: translateX(-50%); font-size: 20px; min-height: 20px; }
#waiter.walking .body { animation: bob 0.35s ease-in-out infinite; }
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-3px)} }

.floatCoin { position: absolute; transform: translate(-50%, -50%); font-weight: 800; color: #15803d; z-index: 6; animation: floatUp 0.9s ease forwards; pointer-events: none; }
@keyframes floatUp { 0%{opacity:1} 100%{opacity:0; transform:translate(-50%,-160%)} }
.pop { animation: pop 0.3s ease; }
@keyframes pop { 0%{transform:translate(-50%,-50%) scale(0.3)} 70%{transform:translate(-50%,-50%) scale(1.12)} 100%{transform:translate(-50%,-50%) scale(1)} }
@keyframes shake { 0%,100%{transform:translate(-50%,-50%)} 25%{transform:translate(-58%,-50%)} 75%{transform:translate(-42%,-50%)} }

/* level-end + how */
#scr-end { align-items: center; text-align: center; gap: 10px; justify-content: center; }
#endEmoji { font-size: 64px; }
#endTitle { font-size: 26px; font-weight: 800; }
#endSub { color: #9f5c72; font-weight: 700; }
.sr { display: flex; gap: 10px; width: 100%; }
.st { flex: 1; background: #fffdfd; border: 3px solid #fbcfe0; border-radius: 14px; padding: 10px 4px; }
.st .sv { font-size: 24px; font-weight: 800; }
.st .slb { font-size: 12px; color: #9f5c72; font-weight: 700; }
#endStars { font-size: 40px; letter-spacing: 6px; min-height: 50px; }

#scr-how .card { background: #fffdfd; border: 3px solid #fbcfe0; border-radius: 16px; padding: 14px; margin-bottom: 10px; font-size: 16px; line-height: 1.55; font-weight: 600; }
#scr-how h2 { margin-bottom: 8px; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #4c0519; color: #fff; font-weight: 800; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 40; max-width: 88vw; text-align: center; }
#toast.on { opacity: 1; }
