:root {
  --bag: #FBF1DC;
  --bag-2: #F3E2BF;
  --line: #E3D3B8;
  --ink: #2B2320;
  --ink-2: #6E625A;
  --ketchup: #E23D28;
  --ketchup-d: #A62A1C;
  --mustard: #FFC629;
  --pickle: #3FA34D;
  --pickle-d: #2B7A36;
  --paper: #FFFDF6;
  --scr: #14301A;
  --scr-text: #8CFF9B;
  --scr-dim: #5BA868;
  --px: 'Pixelify Sans', ui-monospace, monospace;
  --vt: 'VT323', ui-monospace, monospace;
  --b: 2px solid var(--ink);
  --row: clamp(40px, 5.6dvh, 54px);   /* one menu row */
  --rows: 6;                           /* rows to leave room for */
  --chrome: 262px;                     /* header + screen + button + gaps */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bag);
  color: var(--ink);
  font-family: var(--px);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
.spr { image-rendering: pixelated; image-rendering: crisp-edges; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 14px env(safe-area-inset-bottom);
}

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 10px; }
.logo { display: flex; align-items: center; gap: 6px; text-decoration: none; }
.logo-fries { width: 24px; height: 24px; background-size: 24px 24px; image-rendering: pixelated; }
.logo-word { font-weight: 700; font-size: 21px; letter-spacing: 0.3px; line-height: 1; }
.logo-word .l1 { color: var(--ketchup); }
.top-right { display: flex; align-items: center; gap: 8px; }
.chip, .icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  height: 32px; min-width: 32px; padding: 0 8px;
  background: none; border: var(--b); border-radius: 0;
  font-weight: 700; font-size: 15px;
}
.icon-btn { padding: 0; width: 32px; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: var(--ink); stroke-width: 2; shape-rendering: crispEdges; }
.chip:active, .icon-btn:active { background: var(--bag-2); }
.badge {
  position: absolute; top: -7px; right: -7px;
  min-width: 16px; height: 16px; padding: 0 3px;
  background: var(--ketchup); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.badge.in { position: static; margin-left: 6px; }

.modebar {
  margin: 0 0 8px; padding: 5px 10px;
  background: var(--bag-2);
  font-size: 13px; display: flex; justify-content: space-between; gap: 8px;
}
.modebar a { font-weight: 700; }

/* ---------- stage ---------- */
.stage { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.road {
  position: relative;
  height: max(150px, calc(100dvh - var(--chrome) - var(--rows) * var(--row)));
  border: var(--b);
  overflow: hidden;
  background: #7EC8F2;
  cursor: pointer;
}
.road canvas { display: block; }
.bubble {
  position: absolute; left: 8px; top: 8px; max-width: 70%;
  padding: 5px 8px 6px;
  background: var(--paper); border: var(--b);
  font-size: 14px; line-height: 1.2; font-weight: 600;
  opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
.bubble.on { opacity: 1; }
.bubble::after {
  content: ''; position: absolute; bottom: -8px; left: var(--tail, 18px);
  width: 8px; height: 8px; background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

/* order screen: one number */
.screen {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--scr); color: var(--scr-text);
  padding: 7px 12px 8px;
  font-family: var(--vt);
  text-shadow: 0 0 5px rgba(140, 255, 155, 0.4);
  overflow: hidden;
}
.screen::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}
.scr-big { display: flex; align-items: baseline; gap: 6px; flex: none; }
.scr-time { margin-left: auto; font-size: 24px; color: var(--scr-dim); }
.scr-val { font-size: 40px; line-height: 0.9; }
.scr-label { font-size: 20px; color: var(--scr-dim); }
/* the tray: 4 courses */
.tray { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; position: relative; z-index: 1; }
.slot { min-width: 0; padding: 3px 3px 4px; overflow: hidden; border: 1px solid rgba(140, 255, 155, 0.22); }
.slot small { display: block; font-size: 13px; line-height: 1; color: var(--scr-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot span { display: flex; align-items: center; gap: 2px; height: 18px; margin-top: 2px; font-size: 17px; line-height: 1; color: var(--scr-dim); }
.slot img { width: 16px; height: 16px; flex: none; }
.slot.now { border-color: var(--scr-text); }
.slot.now small { color: var(--scr-text); }
.slot.got span { color: var(--scr-text); }
.slot.stamp { animation: stampin 0.25s steps(3) both; }
.screen.over .slot { border-color: rgba(255, 138, 122, 0.3); }
.screen.over .slot.got span, .screen.over .slot.now small { color: #FF8A7A; }
.screen.over { background: #3A1410; color: #FF8A7A; text-shadow: none; }
.screen.over .scr-label, .screen.over .scr-time { color: #C46A5C; }
.screen.flash { animation: flash 0.3s steps(2) 2; }
.screen.hurry .scr-time { color: #FF8A7A; animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.slot.m-exact { border-color: #FFD84A; } .slot.m-exact span { color: #FFD84A; }
.slot.m-green { border-color: var(--scr-text); }
.slot.m-yellow { border-color: #FFE36B; } .slot.m-yellow span { color: #FFE36B; }
.slot.m-far { border-color: #FFB36B; } .slot.m-far span { color: #FFB36B; }
.slot.m-over { border-color: #FF6B5B; background: rgba(255, 107, 91, 0.18); } .slot.m-over span { color: #FF8A7A; }

@keyframes flash { 50% { background: #7A2A20; } }


/* menu: a simple list */
.board { display: flex; flex-direction: column; gap: 10px; }
.menu { background: var(--paper); border: var(--b); }
.tile {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: var(--row);
  padding: 0 12px 0 8px;
  background: none; border: 0; border-top: 1px dashed var(--line);
  text-align: left; font-size: 18px; font-weight: 500;
}
.tile:first-child { border-top: 0; }
.tile img { width: 32px; height: 32px; flex: none; }
.tile .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile:hover { background: #FFF6DA; }
.tile.sel { background: var(--mustard); font-weight: 700; }
.menu.picked .tile:not(.sel) { opacity: 0.4; }
.menu.locked .tile { pointer-events: none; }
.tile.pop { animation: pop 0.2s steps(3) both; }
.tile .tag { flex: none; font-family: var(--vt); font-size: 22px; line-height: 1; animation: stampin 0.25s steps(3) both; }
@keyframes pop { from { opacity: 0; transform: translateX(-6px); } }
@keyframes stampin { from { transform: scale(1.8); opacity: 0; } }

.order-btn {
  height: 50px;
  background: var(--ketchup); color: #fff;
  border: var(--b); box-shadow: 0 3px 0 var(--ink);
  font-size: 17px; font-weight: 700; letter-spacing: 0.3px;
  transition: transform 0.06s, box-shadow 0.06s;
}
.order-btn:not(:disabled):active, .order-btn.press { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.order-btn:disabled { background: none; color: var(--ink-2); border-color: var(--line); box-shadow: none; cursor: default; }

/* ---------- end screen ---------- */
.end { display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
.end .paper {
  background: var(--paper);
  border: var(--b);
  padding: 12px 14px 14px;
  font-family: var(--vt);
  animation: rollout 0.7s steps(7) both;
}
@keyframes rollout { from { clip-path: inset(0 0 100% 0); } }
.rc-head { text-align: center; font-size: 20px; color: var(--ink-2); margin-bottom: 6px; }
.rc-rule { border: 0; border-top: 1px dashed var(--line); margin: 6px 0; }
.rc-lines { list-style: none; margin: 0; padding: 0; font-size: 21px; line-height: 1.15; }
.rc-lines li { display: flex; justify-content: space-between; gap: 8px; }
.rc-lines .it { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-sum { display: flex; justify-content: space-between; font-size: 24px; line-height: 1.1; }
.rc-sum.dim { color: var(--ink-2); font-size: 21px; }
.rc-stamp {
  display: block; width: max-content; margin: 10px auto 4px;
  padding: 2px 10px 4px;
  border: 3px solid currentColor;
  font-family: var(--px); font-weight: 700; font-size: 22px;
  transform: rotate(-3deg);
  animation: stampin2 0.3s steps(3) 0.6s both;
}
.rc-stamp.exact { color: #C98F00; background: #FFF3C2; }
.rc-stamp.green { color: var(--pickle-d); }
.rc-stamp.yellow { color: #B07D06; }
.rc-stamp.far { color: #D2691E; }
.rc-sum.over { color: var(--ketchup); }
.rc-stamp.over { color: #fff; background: var(--ketchup); border-color: var(--ketchup-d); }
.rc-lines small { color: var(--ink-2); font-size: 16px; }
@keyframes stampin2 { from { transform: rotate(-3deg) scale(2); opacity: 0; } }
.rc-title { text-align: center; font-family: var(--px); font-size: 15px; color: var(--ink-2); }
.share-btn {
  height: 48px;
  background: var(--ketchup); color: #fff;
  border: var(--b); box-shadow: 0 3px 0 var(--ink);
  font-size: 18px; font-weight: 700;
}
.share-btn:active { transform: translateY(3px); box-shadow: none; }
.share-btn.copied { background: var(--pickle); }
.rc-next { margin: 0; text-align: center; font-size: 15px; color: var(--ink-2); }
.link-btn { display: block; background: none; border: 0; padding: 4px; text-align: center; font-size: 14px; font-weight: 600; text-decoration: underline; color: var(--ink-2); }
.prices { background: var(--paper); border: var(--b); padding: 8px 12px 10px; font-family: var(--vt); font-size: 19px; line-height: 1.15; }
.prices h4 { margin: 8px 0 2px; font-family: var(--px); font-size: 13px; color: var(--ink-2); }
.prices h4:first-child, .prices .got + h4 { margin-top: 2px; }
.prices .row { display: flex; justify-content: space-between; gap: 8px; }
.prices .row.you { color: var(--ketchup); }
.prices .row.over:not(.you) { color: #B3A79A; }
.prices .got { margin: 0 0 6px; font-family: var(--px); font-size: 14px; line-height: 1.3; }
.prices .small { font-family: var(--px); margin: 8px 0 0; }

.shake { animation: shake 0.4s steps(5); }
@keyframes shake { 25% { transform: translate(-3px, 1px); } 50% { transform: translate(3px, -1px); } 75% { transform: translate(-2px, -1px); } }

/* ---------- footer ---------- */
.foot { padding: 14px 0 16px; font-size: 12px; color: var(--ink-2); text-align: center; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; top: 60px; display: grid; justify-items: center; gap: 6px; pointer-events: none; z-index: 40; }
.toast { padding: 6px 12px; background: var(--ink); color: var(--paper); font-size: 14px; animation: toast 0.2s steps(3) both; }
@keyframes toast { from { transform: translateY(-6px); opacity: 0; } }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- sheets ---------- */
.sheet {
  width: min(400px, calc(100vw - 24px));
  max-height: min(86dvh, 700px);
  padding: 16px 16px 18px;
  background: var(--bag);
  border: var(--b);
  color: var(--ink);
  overflow: auto;
}
.sheet::backdrop { background: rgba(43, 35, 32, 0.4); }
.sheet h2 { margin: 0 0 10px; font-size: 21px; }
.sheet-x { position: absolute; right: 10px; top: 10px; width: 30px; height: 30px; background: none; border: var(--b); font-size: 18px; line-height: 1; }
.lede { margin: 0 0 10px; font-size: 14px; color: var(--ink-2); }
.small { font-size: 13px; }
.muted { color: var(--ink-2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 42px; padding: 0 14px;
  background: var(--paper); border: var(--b);
  font-weight: 600; font-size: 15px; text-decoration: none;
}
.btn:active { background: var(--bag-2); }
.btn.primary { background: var(--ketchup); color: #fff; }
.btn.wide { width: 100%; margin-top: 8px; }
.more .btn.wide:first-child { margin-top: 0; }
.how { margin: 0 0 12px; padding-left: 20px; font-size: 15px; line-height: 1.4; }
.bands { display: grid; gap: 5px; margin: 0 0 10px; }
.bands div { display: grid; grid-template-columns: 20px auto 1fr; gap: 8px; align-items: center; font-size: 14px; }
.bands small { color: var(--ink-2); }
.sq { width: 16px; height: 16px; display: inline-block; }
.sq.exact { background: #F2B418; } .sq.green { background: var(--pickle); }
.sq.yellow { background: var(--mustard); } .sq.red { background: var(--ketchup); }
.sq.far { background: #F28C28; } .sq.over { background: var(--ketchup); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: var(--paper); border: 1px solid var(--line); padding: 6px 4px; text-align: center; }
.stat b { display: block; font-family: var(--vt); font-size: 28px; line-height: 1; }
.stat span { font-size: 11px; color: var(--ink-2); }
.mini-h { margin: 14px 0 6px; font-size: 14px; }
.dist { display: grid; gap: 4px; }
.dist .row { display: grid; grid-template-columns: 24px 1fr; gap: 6px; align-items: center; font-size: 13px; }
.dist .bar { height: 18px; min-width: 18px; font-family: var(--vt); font-size: 16px; line-height: 18px; padding: 0 5px; text-align: right; }
.dist .bar.exact { background: #F2B418; } .dist .bar.green { background: var(--pickle); color: #fff; }
.dist .bar.yellow { background: var(--mustard); } .dist .bar.red { background: var(--ketchup); color: #fff; }
.dist .bar.far { background: #F28C28; color: #fff; } .dist .bar.over { background: var(--ketchup); color: #fff; }

.book-chain { margin: 12px 0 4px; font-size: 14px; display: flex; justify-content: space-between; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 5px; }
.stk { background: var(--paper); border: 1px solid var(--line); padding: 4px 3px 5px; text-align: center; font-size: 10px; line-height: 1.1; }
.stk img { width: 32px; height: 32px; display: block; margin: 0 auto 2px; }
.stk.no { background: none; color: #A39182; border-style: dashed; }
.stk .p { display: block; font-family: var(--vt); font-size: 15px; color: var(--ink); }

.garage { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.car { background: var(--paper); border: 1px solid var(--line); padding: 8px; text-align: center; font-size: 13px; }
.car img { width: 96px; height: 44px; display: block; margin: 0 auto 4px; }
.car.locked img { filter: grayscale(1) opacity(0.35); }
.car.locked { color: #A39182; border-style: dashed; }
.car.on { background: var(--mustard); border-color: var(--ink); }
.car small { display: block; color: var(--ink-2); }

.past { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.past a { display: block; padding: 7px 2px; text-align: center; background: var(--paper); border: 1px solid var(--line); text-decoration: none; font-size: 12px; font-weight: 600; }
.past a small { display: block; font-weight: 400; font-size: 11px; letter-spacing: -1px; min-height: 15px; }

@media (max-width: 380px) {
  .logo-fries { display: none; }
  .scr-val { font-size: 30px; }
  .slot small { font-size: 11px; }
  .slot span { font-size: 17px; }
  .tile { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.menu:empty { display: none; }

/* big screens: a wide road on top, everything else below it */
@media (min-width: 760px) {
  .app { max-width: 1000px; padding: 0 28px; }
  .top { padding: 18px 0 14px; }
  .logo-fries { width: 32px; height: 32px; background-size: 32px 32px; }
  .logo-word { font-size: 28px; }
  .chip, .icon-btn { height: 40px; min-width: 40px; font-size: 18px; }
  .icon-btn { width: 40px; }
  .stage { gap: 14px; }
  :root { --row: clamp(52px, 7dvh, 68px); --rows: 3; --chrome: 345px; }
  .bubble { font-size: 18px; padding: 7px 11px 8px; }
  .screen { padding: 10px 18px 12px; }
  .scr-val { font-size: 56px; }
  .scr-label { font-size: 26px; }
  .scr-time { font-size: 32px; }
  .tray { gap: 10px; margin-top: 8px; }
  .slot { padding: 6px 10px 7px; }
  .slot small { font-size: 18px; }
  .slot span { height: 32px; font-size: 30px; gap: 8px; }
  .slot img { width: 32px; height: 32px; }
  .board { gap: 14px; }
  .menu { display: grid; grid-template-columns: 1fr 1fr; }
  .tile { font-size: 21px; gap: 14px; padding: 0 16px 0 12px; border-top: 1px dashed var(--line); }
  .tile:nth-child(2) { border-top: 0; }
  .tile:nth-child(odd) { border-right: 1px dashed var(--line); }
  .tile img { width: 48px; height: 48px; }
  .tile .tag { font-size: 28px; }
  .order-btn { height: 60px; font-size: 22px; }
  .end { width: 100%; max-width: 560px; margin: 0 auto; }
  .foot { font-size: 14px; }
}
