:root {
  --bg: #ffe9cc; --ink: #4a3426; --soft: #8a6a55; --wood: #c98a55; --wood2: #a86c3c;
  --tile: #f7f3ea; --tile2: #e9e1d2; --accent: #ff8a3d; --ok: #5cc46b; --bad: #ef5a5a; --gold: #f2b833;
  --card: #fffaf2;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--ink); font-family: 'Mali', system-ui, sans-serif; touch-action: manipulation; }
#app { max-width: 480px; height: 100dvh; margin: 0 auto; position: relative; overflow: hidden;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button { font-family: inherit; color: inherit; border: 0; cursor: pointer; }

.btn { background: var(--accent); color: #fff; font-weight: 700; font-size: 16px; padding: 10px 16px; border-radius: 14px;
  box-shadow: 0 4px 0 #d4651f; transition: transform .06s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d4651f; }
.btn.alt { background: #fff; color: var(--ink); box-shadow: 0 4px 0 #e0cdb5; }
.btn.big { display: block; width: 100%; font-size: 18px; padding: 13px; margin: 8px 0; }
.btn.round { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 18px; flex: none; }
.btn:disabled { opacity: .45; transform: none; }
.pill { background: #fff; border-radius: 99px; padding: 6px 12px; font-weight: 700; box-shadow: 0 2px 0 #e0cdb5; }

/* ---------- menu ---------- */
#menu, #shop { height: 100%; overflow-y: auto; padding: 16px; }
.title { text-align: center; margin: 10px 0 14px; }
.logo { width: 150px; margin: 0 auto; position: relative; animation: bob 2.4s ease-in-out infinite; }
.logo svg { width: 100%; height: auto; display: block; overflow: visible; }
.logo .hat { position: absolute; top: -10px; right: 18px; font-size: 40px; transform: rotate(12deg); }
.res-rexy { width: 110px; margin: -6px auto 0; } .res-rexy svg { width: 100%; height: auto; display: block; overflow: visible; }
.title h1 { margin: 0; font-size: 36px; color: #e2621b; text-shadow: 0 3px 0 #fff; }
.title p { margin: 4px 0 0; color: var(--soft); }
.bar-top { display: flex; align-items: center; gap: 8px; justify-content: center; margin-bottom: 14px; }
.bar-top h2 { flex: 1; margin: 0; text-align: center; }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lv { background: #fff; border-radius: 14px; padding: 8px 2px; display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 4px 0 #e0cdb5; min-height: 82px; }
.lv b { font-size: 22px; }
.lvst { color: var(--gold); font-size: 12px; letter-spacing: -1px; }
.lvmenu { font-size: 10px; margin-top: 2px; }
.lv.locked { opacity: .5; }
.menu-btns { margin-top: 16px; }
.testtag { text-align: center; color: var(--bad); font-weight: 700; }

/* ---------- shop ---------- */
.upg { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 16px; padding: 10px; margin-bottom: 8px; box-shadow: 0 3px 0 #e8d8c3; }
.ue { font-size: 32px; width: 44px; text-align: center; }
.ut { flex: 1; display: flex; flex-direction: column; }
.ut small { color: var(--soft); }
.pips { display: flex; gap: 3px; margin-top: 4px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: #eadcc8; }
.pips i.on { background: var(--accent); }
.buy { min-width: 84px; font-size: 14px; }

/* ---------- game ---------- */
#game { height: 100%; display: flex; flex-direction: column; }
.hud { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fff3e2; }
.hud-mid { flex: 1; }
.hud-row { display: flex; justify-content: space-between; font-size: 14px; }
#clock.late { color: var(--bad); animation: pulse .6s infinite alternate; }
.goalbar { position: relative; height: 12px; background: #eadcc8; border-radius: 6px; margin-top: 4px; }
.goalbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffc45c, #ff8a3d); border-radius: 6px; transition: width .3s; }
.goalbar em { position: absolute; top: -6px; transform: translateX(-60%); font-style: normal; font-size: 16px; color: #cdb89e; }
.goalbar em.on { color: var(--gold); text-shadow: 0 0 4px #fff; }
.hud-coin { text-align: right; font-weight: 700; font-size: 20px; min-width: 70px; }
.hud-coin small { display: block; font-size: 11px; color: var(--accent); height: 14px; }

.street { flex: 1.25; display: flex; align-items: flex-end; gap: 4px; padding: 30px 6px 0; position: relative;
  background: linear-gradient(#bfe7ff 0 30%, #ffe3b8 30%); min-height: 0; }
.street::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 26px;
  background: repeating-linear-gradient(90deg, #ff8a3d 0 28px, #fff6ea 28px 56px);
  -webkit-mask: radial-gradient(14px 10px at 14px 100%, #0000 98%, #000) 0 0 / 28px 100%;
          mask: radial-gradient(14px 10px at 14px 100%, #0000 98%, #000) 0 0 / 28px 100%;
  filter: drop-shadow(0 3px 0 #0001); }
.seat { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; height: 100%; }
.seat.empty .stool { width: 46px; height: 16px; border-radius: 8px; background: var(--wood2); margin-bottom: 4px; opacity: .4; }
.guest { width: 88px; max-width: 100%; }
.guest svg { width: 100%; height: auto; display: block; overflow: visible; }
.seat.happy .guest { animation: hop .4s ease-out 2; }
.seat.wait.m2 .guest { animation: wobble .3s infinite; }
.seat.happy, .seat.angry { animation: leave 1.2s ease-in forwards; }
.seat.vip .bubble { border-color: var(--gold); }
.bubble { background: #fff; border: 3px solid #f0dcc4; border-radius: 14px; padding: 4px; width: 100%; max-width: 110px;
  display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px; position: relative; }
.bubble::after { content: ''; position: absolute; bottom: -9px; left: 50%; margin-left: -7px; border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; }
.dish { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.de { font-size: 26px; }
.dn { font-size: 9px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ing { font-size: 13px; letter-spacing: -1px; }
.say { font-size: 30px; text-align: center; }
.pat { width: 78%; height: 7px; background: #0002; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.pat i { display: block; height: 100%; width: 100%; }

.counter { display: flex; gap: 8px; padding: 8px; justify-content: center; background: linear-gradient(var(--wood), var(--wood2)); align-items: stretch; }
.plate { flex: 0 1 84px; min-width: 0; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(#fff 55%, #e9e4dc 56% 64%, #fff 65%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; border: 3px solid transparent; box-shadow: 0 3px 0 #8b5730; }
.plate.sel { border-color: var(--accent); box-shadow: 0 0 0 3px #ffd2ad, 0 3px 0 #8b5730; }
.plate.ready { animation: glow 1s infinite alternate; }
.pd { font-size: 32px; line-height: 1; }
.plate small { font-size: 9px; font-weight: 700; }
.pi { font-size: 20px; letter-spacing: -3px; }
.hint { font-size: 10px; color: #b9a690; font-style: normal; letter-spacing: 0; }
.ii { position: relative; display: inline-block; }
.ii.cut::after { content: '✂'; position: absolute; right: -4px; bottom: -2px; font-size: 9px; color: #333; }
.trash { width: 48px; border-radius: 12px; background: #8a9aa8; font-size: 24px; box-shadow: 0 3px 0 #5f6d79; }

.kitchen { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; align-content: center; justify-content: center;
  background: repeating-conic-gradient(var(--tile) 0 25%, var(--tile2) 0 50%) 0 0 / 28px 28px; min-height: 0; }
.st { width: calc(25% - 5px); min-width: 72px; height: 86px; border-radius: 14px; background: #5b5f66; color: #fff; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 4px 0 #3c3f44; }
.st.board { background: #d9a86c; box-shadow: 0 4px 0 #a97a44; }
.st.drink { background: #79a6d9; box-shadow: 0 4px 0 #4f7cb0; }
.st.fryer { background: #c9a227; box-shadow: 0 4px 0 #957713; }
.st.done { outline: 3px solid #b6f5be; }
.st.burnt { background: #2d2a28; }
.se { font-size: 26px; opacity: .45; }
.si { font-size: 34px; line-height: 1; }
.si.cook { animation: sizzle .25s infinite alternate; }
.si.done { animation: hop .5s infinite alternate; }
.st.board .si.cook { animation: none; }
.taps { position: absolute; top: 3px; right: 6px; font-size: 10px; background: #fff; color: var(--ink); border-radius: 8px; padding: 0 5px; }
.sn { position: absolute; bottom: 3px; font-size: 9px; opacity: .85; }
.sbar { width: 70%; height: 6px; background: #0005; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.sbar i { display: block; height: 100%; width: 0; }

.pantry { display: flex; gap: 6px; padding: 8px 8px 12px; background: #8a5a36; overflow-x: auto; }
.bin { flex: 1; min-width: 52px; height: 64px; border-radius: 12px; background: #fff3e2; display: flex; flex-direction: column;
  align-items: center; justify-content: center; box-shadow: 0 4px 0 #5d3b20; }
.bin span { font-size: 28px; line-height: 1; }
.bin small { font-size: 9px; }
.bin:active, .st:active, .plate:active { transform: translateY(2px); }

/* ---------- modal / feedback ---------- */
#modal { position: fixed; inset: 0; background: #3a24154d; display: none; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
#modal.show { display: flex; }
.card { background: var(--card); border-radius: 22px; padding: 18px; width: 100%; max-width: 380px; max-height: 92dvh; overflow-y: auto;
  box-shadow: 0 8px 0 #e0cdb5; animation: pop .25s ease-out; }
.card h2 { margin: 0 0 10px; text-align: center; }
.how { padding-left: 20px; margin: 0 0 8px; line-height: 1.5; font-size: 14px; }
.how li { margin-bottom: 6px; }
.res-stars { text-align: center; font-size: 46px; color: #e3d5c2; }
.res-stars span.on { color: var(--gold); display: inline-block; animation: starIn .5s both; }
.res div { display: flex; justify-content: space-between; padding: 4px 2px; border-bottom: 1px dashed #ead9c3; font-size: 15px; }
.res span { color: var(--soft); }
.unlock { background: #fff0d6; border-radius: 12px; padding: 8px; text-align: center; font-size: 14px; }
.row2 { display: flex; gap: 8px; } .row2 .btn { flex: 1; }

#toast { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -10px); background: #4a3426e6; color: #fff; padding: 8px 14px;
  border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.float { position: fixed; transform: translateX(-50%); font-weight: 700; font-size: 16px; pointer-events: none; z-index: 25;
  text-shadow: 0 2px 0 #fff, 0 0 4px #fff; animation: floatUp 1.1s ease-out forwards; white-space: nowrap; }
.float.gold { color: #d48a00; font-size: 19px; } .float.ok { color: #2f9b45; } .float.bad { color: var(--bad); }
.shake { animation: shake .35s; }

@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes hop { 50% { transform: translateY(-10px) scale(1.05); } }
@keyframes wobble { 50% { transform: rotate(4deg); } }
@keyframes sizzle { to { transform: translateY(-2px) rotate(-3deg); } }
@keyframes glow { to { box-shadow: 0 0 14px 4px #ffe066, 0 3px 0 #8b5730; } }
@keyframes pulse { to { opacity: .4; } }
@keyframes leave { 0%, 60% { opacity: 1; } 100% { opacity: 0; transform: translateY(16px); } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
@keyframes floatUp { to { transform: translate(-50%, -50px); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
