/* A weekly supermarket flyer: shouting yellow, sale red, navy ink, thermal receipts. */
@font-face { font-family: 'Bowlby One'; src: url(fonts/bowlby-one-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'VT323'; src: url(fonts/vt323-latin-400-normal.woff2) format('woff2'); font-display: swap; }
:root {
  --yellow: #ffd21f; --red: #e3162d; --ink: #14213d; --paper: #fbfaf3; --blue: #1f6feb; --green: #0d8a4f; --steel: #dfe6ec;
  --flyer: 'Bowlby One', 'Arial Black', Impact, system-ui, sans-serif; --till: 'VT323', ui-monospace, Menlo, Consolas, 'Noto Sans Mono', monospace, system-ui;
  --safeT: env(safe-area-inset-top, 0px); --safeB: env(safe-area-inset-bottom, 0px); --safeL: env(safe-area-inset-left, 0px); --safeR: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--yellow); color: var(--ink); font-family: var(--till); font-size: 20px; overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body.playing { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
canvas#game { position: fixed; inset: 0; display: block; outline: none; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.noscript { padding: 20px; }

/* ---- price-tag buttons ---- */
.tag { position: relative; display: block; width: 100%; border: 3px solid var(--ink); background: var(--yellow); padding: 10px 16px; font-family: var(--flyer); font-size: 19px; line-height: 1.15; text-align: left; border-radius: 3px 14px 14px 3px; box-shadow: 4px 4px 0 var(--ink); }
.tag:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.tag.big { font-size: 25px; padding: 12px 18px 13px; }
.tag.red { background: var(--red); color: #fff; }
.tag .t { display: block; }
.tag .s { display: block; font-family: var(--till); font-size: 20px; line-height: 1.05; margin-top: 3px; }
.link { background: none; border: 0; padding: 8px 6px; text-decoration: underline; text-underline-offset: 3px; font-size: 21px; min-height: 40px; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper); display: grid; place-items: center; padding: 0; box-shadow: 2px 3px 0 var(--ink); }
.round svg { width: 24px; height: 24px; fill: currentColor; }

/* ---- HUD ---- */
#btnMute { position: fixed; z-index: 30; top: calc(10px + var(--safeT)); right: calc(10px + var(--safeR)); }
#btnMute .off { display: none; } #btnMute.muted .off { display: block; } #btnMute.muted .on { display: none; }
body.playing #btnMute { top: calc(66px + var(--safeT)); width: 40px; height: 40px; opacity: .9; }
#hud { position: fixed; z-index: 20; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; position: absolute; top: calc(10px + var(--safeT)); }
#btnRestart { left: calc(10px + var(--safeL)); background: var(--yellow); }
#btnPause { right: calc(10px + var(--safeR)); }
#tagWrap { position: absolute; top: calc(8px + var(--safeT)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
#timeTag { background: var(--yellow); border: 3px solid var(--ink); border-radius: 4px; padding: 2px 16px 4px; box-shadow: 3px 3px 0 var(--ink); transform: rotate(-1.5deg); }
#time { font-family: var(--flyer); font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; display: inline-block; min-width: 3.2ch; text-align: center; }
#delta { margin-top: 6px; background: var(--paper); border: 2px solid var(--ink); padding: 0 10px; font-family: var(--flyer); font-size: 17px; line-height: 1.5; transform: rotate(1deg); }
#delta.good { background: var(--green); color: #fff; }
#delta.bad { background: var(--red); color: #fff; }
#list { position: absolute; top: calc(66px + var(--safeT)); left: calc(10px + var(--safeL)); max-width: 72vw; background: var(--paper); border: 2px solid var(--ink); padding: 0 8px 1px; font-size: 19px; line-height: 1.1; }
#rivalTag { position: absolute; top: calc(92px + var(--safeT)); left: calc(10px + var(--safeL)); max-width: 72vw; background: var(--ink); color: var(--paper); padding: 0 8px 1px; font-size: 18px; line-height: 1.15; }
#tannoy { position: fixed; z-index: 25; left: 50%; top: calc(122px + var(--safeT)); transform: translateX(-50%); width: min(88vw, 520px); background: var(--ink); color: var(--paper); padding: 4px 12px 6px; font-size: 20px; line-height: 1.1; text-align: center; border-radius: 3px; pointer-events: none; }
body:not(.playing) #tannoy { top: calc(10px + var(--safeT)); }
#callout { position: fixed; z-index: 24; top: 26%; left: 50%; transform: translateX(-50%) rotate(-3deg); font-family: var(--flyer); font-size: 26px; background: var(--paper); border: 3px solid var(--ink); padding: 2px 14px 4px; width: max-content; max-width: 88vw; text-align: center; line-height: 1.15; pointer-events: none; }
#callout.good { background: var(--green); color: #fff; }
#callout.bad { background: var(--red); color: #fff; }
#hint { position: fixed; z-index: 25; left: 50%; top: 34%; transform: translateX(-50%); width: min(86vw, 460px); background: var(--paper); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); padding: 10px 14px 12px; text-align: center; font-size: 23px; line-height: 1.1; pointer-events: none; }
#hint .go { font-family: var(--flyer); font-size: 19px; margin-top: 8px; color: var(--red); }

/* ---- touch: huge invisible zones, visible buttons where the thumbs rest ---- */
#touch { position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; top: 150px; display: flex; touch-action: none; -webkit-user-select: none; user-select: none; }
.zone { position: relative; height: 100%; touch-action: none; }
#zSteer { flex: 58 1 0; }
#zSkid { flex: 42 1 0; }
body.swap #touch { flex-direction: row-reverse; }
.pad { position: absolute; bottom: calc(22px + var(--safeB)); width: 44%; max-width: 104px; height: 92px; border: 3px solid var(--ink); border-radius: 14px; background: rgba(251, 250, 243, .78); display: grid; place-items: center; pointer-events: none; }
.pad svg { width: 44px; height: 44px; fill: var(--ink); }
.pad.on { background: var(--yellow); transform: translateY(3px); }
#tL { left: calc(12px + var(--safeL)); }
#tR { left: calc(12px + var(--safeL) + min(44%, 104px) + 8px); }
body.swap #tL { left: auto; right: calc(12px + var(--safeR) + min(44%, 104px) + 8px); }
body.swap #tR { left: auto; right: calc(12px + var(--safeR)); }
#tS { right: calc(12px + var(--safeR)); width: 76%; max-width: 150px; font-family: var(--flyer); font-size: 21px; line-height: 1; text-align: center; overflow: hidden; overflow-wrap: anywhere; padding: 2px; background: rgba(227, 22, 45, .84); color: #fff; }
#tS.on { background: var(--red); }
body.swap #tS { right: auto; left: calc(12px + var(--safeL)); }

/* ---- menu ---- */
#menu { position: fixed; z-index: 10; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }
.mast { padding: calc(18px + var(--safeT)) 16px 0; min-height: 31vh; pointer-events: none; }
#logo { margin: 0; font-family: var(--flyer); font-weight: 400; font-size: clamp(44px, 14.5vw, 74px); line-height: .95; color: var(--red); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 5px 0 var(--ink); transform: rotate(-2.5deg); transform-origin: left bottom; letter-spacing: -.01em; }
#tagline { display: inline-block; margin: 12px 0 0; padding: 1px 9px 3px; background: var(--ink); color: var(--paper); font-size: 21px; line-height: 1.05; transform: rotate(-1deg); }
.sheet { flex: 1 0 auto; background: var(--yellow); border-top: 4px solid var(--ink); padding: 16px 16px calc(14px + var(--safeB)); }
.deals { display: grid; gap: 12px; }
#shelfTitle { margin: 20px 0 8px; font-family: var(--flyer); font-weight: 400; font-size: 22px; }
#shelf { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; padding-bottom: 12px; border-bottom: 8px solid var(--ink); }
.shelfTag { background: var(--paper); font-family: var(--till); padding: 6px 8px 5px 10px; font-size: 20px; line-height: 1; min-height: 74px; box-shadow: 2px 3px 0 var(--ink); display: flex; flex-direction: column; justify-content: space-between; gap: 3px; border-width: 2px; }
.shelfTag .nm { display: block; }
.shelfTag .price { display: block; font-family: var(--flyer); font-size: 25px; line-height: 1; color: var(--red); font-variant-numeric: tabular-nums; }
.shelfTag .price.none { font-family: var(--till); font-size: 18px; color: #5b6478; }
.shelfTag.shut { background: #ece6c8; color: #5b6478; cursor: not-allowed; box-shadow: none; }
.shelfTag .sc { position: absolute; right: 34px; bottom: 8px; font-size: 17px; color: var(--ink); }
.chip { position: absolute; right: 7px; bottom: 7px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink); }
.chip.m0 { display: none; }
.chip.m1, .stamp.m1 { background: #d58a4a; }
.chip.m2, .stamp.m2 { background: #c9d2db; }
.chip.m3, .stamp.m3 { background: var(--yellow); }
.chip.m4, .stamp.m4 { background: var(--blue); color: #fff; }
#menuLinks { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
#stats { margin: 4px 0; }
#byline { margin: 0; font-size: 18px; line-height: 1.1; color: #3b4563; }
body.land #menu { flex-direction: row; }
body.land .mast { flex: 1 1 0; min-height: 0; }
body.land .sheet { flex: 0 0 min(460px, 52vw); border-top: 0; border-left: 4px solid var(--ink); overflow-y: auto; }
body.land #btnMute { right: calc(min(460px, 52vw) + 14px); }
body.land.playing #btnMute { right: calc(10px + var(--safeR)); }

/* ---- panels ---- */
#panel { position: fixed; z-index: 40; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; justify-content: center; align-items: flex-start; padding: calc(14px + var(--safeT)) 14px calc(14px + var(--safeB)); background: rgba(20, 33, 61, .46); }
.card { width: min(100%, 440px); margin: auto 0; background: var(--paper); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 14px 16px; }
#pTitle { margin: 0 0 8px; font-family: var(--flyer); font-weight: 400; font-size: 26px; line-height: 1.1; color: var(--red); overflow-wrap: anywhere; }
#pBody p { margin: 0 0 10px; line-height: 1.12; font-size: 21px; }
#pBody p.small { font-size: 19px; color: #3b4563; }
#pBody p.unv { background: var(--yellow); border: 2px solid var(--ink); padding: 4px 8px 6px; }
#pBody p.warn { background: var(--red); color: #fff; padding: 4px 8px 6px; }
#pBtns { display: grid; gap: 11px; margin-top: 8px; justify-items: stretch; }
#pBtns .link { justify-self: start; text-align: left; }
#pToast { margin: 8px 0 0; font-size: 19px; line-height: 1.1; min-height: 1em; overflow-wrap: anywhere; }
#pToast:empty { display: none; }
#linkBox { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; padding: 4px 6px; border: 2px solid var(--ink); background: #fff; color: var(--ink); }

/* The receipt: jagged thermal paper, the time printed big. */
#panel.receipt .card { background: transparent; border: 0; box-shadow: none; padding: 0; }
#panel.receipt #pTitle { background: var(--paper); margin: 0; padding: 12px 14px 0; text-align: center; color: var(--ink); font-size: 24px; }
.paper { position: relative; background: var(--paper); padding: 2px 14px 22px; font-size: 21px; line-height: 1.08; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), 97% 100%, 94% calc(100% - 7px), 91% 100%, 88% calc(100% - 7px), 85% 100%, 82% calc(100% - 7px), 79% 100%, 76% calc(100% - 7px), 73% 100%, 70% calc(100% - 7px), 67% 100%, 64% calc(100% - 7px), 61% 100%, 58% calc(100% - 7px), 55% 100%, 52% calc(100% - 7px), 49% 100%, 46% calc(100% - 7px), 43% 100%, 40% calc(100% - 7px), 37% 100%, 34% calc(100% - 7px), 31% 100%, 28% calc(100% - 7px), 25% 100%, 22% calc(100% - 7px), 19% 100%, 16% calc(100% - 7px), 13% 100%, 10% calc(100% - 7px), 7% 100%, 4% calc(100% - 7px), 1% 100%, 0 calc(100% - 7px)); }
.rl { display: flex; justify-content: space-between; gap: 10px; padding: 1px 0; }
.rl.head { justify-content: center; text-align: center; border-bottom: 2px dashed var(--ink); padding-bottom: 5px; margin-bottom: 5px; }
.rl.small { font-size: 18px; color: #3b4563; }
.rl.center { justify-content: center; text-align: center; }
.rl.good { color: var(--green); }
.rl.bad { color: var(--red); }
.rl.total { font-family: var(--flyer); font-size: 34px; line-height: 1.2; border-top: 2px dashed var(--ink); border-bottom: 2px dashed var(--ink); margin: 5px 0; padding: 3px 0 2px; }
.rl.rumour { font-size: 19px; background: var(--yellow); margin: 6px -4px; padding: 3px 7px 5px; }
.barcode { display: flex; justify-content: center; align-items: stretch; height: 34px; margin: 10px 0 4px; gap: 2px; }
.barcode i { display: block; background: var(--ink); }
.barcode i.b0 { width: 1px; } .barcode i.b1 { width: 2px; } .barcode i.b2 { width: 4px; } .barcode i.b3 { width: 3px; background: transparent; }
.stamp { position: absolute; bottom: 30px; right: 12px; border: 4px solid var(--ink); border-radius: 50%; font-family: var(--flyer); font-size: 15px; padding: 15px 7px; line-height: 1; transform: rotate(14deg); opacity: .94; min-width: 72px; text-align: center; pointer-events: none; animation: stampIn .22s ease-out .15s both; }
@keyframes stampIn { from { transform: rotate(30deg) scale(2.2); opacity: 0; } to { transform: rotate(14deg) scale(1); opacity: .94; } }
#panel.receipt #pBtns { margin-top: 10px; }
#panel.receipt .link { color: var(--paper); }
#panel.receipt #pToast { color: var(--paper); }
#panel.pausePanel #pBtns .link { padding: 4px 6px; min-height: 36px; }

.carts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.cartBtn { background: var(--steel); border: 2px solid var(--ink); padding: 4px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 0; font-size: 18px; line-height: 1; text-align: center; }
.cartBtn canvas { width: 90px; height: 68px; }
.cartBtn canvas.dim { filter: grayscale(1); opacity: .5; }
.cartBtn small { font-size: 16px; min-height: 1em; color: #3b4563; }
.cartBtn.used { background: var(--yellow); }
.cartBtn.shut { cursor: not-allowed; }

@media (min-width: 600px) and (min-height: 500px) { #shelf { grid-template-columns: 1fr 1fr 1fr; } body.land #shelf { grid-template-columns: 1fr 1fr; } }
@media (orientation: landscape) and (max-height: 500px) {
  #touch { top: 70px; }
  #tannoy { top: calc(62px + var(--safeT)); left: 60%; width: min(52vw, 460px); font-size: 18px; }
  .pad { height: 84px; bottom: calc(12px + var(--safeB)); max-width: 92px; }
  #tR { left: calc(12px + var(--safeL) + min(44%, 92px) + 8px); }
  #tS { max-width: 130px; }
  #logo { font-size: clamp(38px, 8vw, 60px); }
  #time { font-size: 28px; }
  #list { top: calc(64px + var(--safeT)); }
  #rivalTag { top: calc(88px + var(--safeT)); }
  body.playing #btnMute, body.land.playing #btnMute { top: calc(10px + var(--safeT)); right: calc(66px + var(--safeR)); width: 48px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) { .stamp { animation: none; } .tag:active { transform: none; } }
body.panelOpen #btnMute { display: none; }
body.panelOpen.paused #btnMute { display: grid; z-index: 45; }
.rl.quip { margin-top: 6px; }
