/* Every number on the page reads in VT323, the clear font of the prices, even inside words set in
   Pixelify Sans, whose 5s, 6s and 8s look alike. This face covers only the digits and %, sits first
   in --pixel, and is scaled to match Pixelify's size. It never synthesizes bold. */
@font-face {
  font-family: "Clear digits";
  src: url(https://fonts.gstatic.com/s/vt323/v18/pxiKyp0ihIEF2isfFJXUdVNF.woff2) format("woff2");
  unicode-range: U+0030-0039, U+0025;
  font-weight: 100 900;
  size-adjust: 140%;
  font-display: swap;
}

/* Endesga 32 colours (game/art.xml has the full palette). The world is bright; the task card is
   calm, and colour inside it goes on what matters: place values and the decimal point. */
:root {
  --night: #181425;
  --navy: #262b44;
  --dusk: #3a4466;
  --slate: #5a6988;
  --steel: #8b9bb4;
  --paper: #fbf3df;
  --cream: #ead4aa;
  --orange: #f77622;
  --amber: #feae34;
  --yellow: #fee761;
  --lime: #63c74d;
  --green: #3e8948;
  --deep: #193c3e;
  --sky: #0099db;
  --blue: #124e89;
  --plum: #68386c;
  --magenta: #b55088;
  --pink: #f6757a;
  --rust: #be4a2f;
  --brown: #733e39;
  --pixel: "Clear digits", "Pixelify Sans", system-ui, sans-serif;
  --digits: "VT323", ui-monospace, monospace;
  --edge: 3px solid var(--night);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--navy);
  color: var(--paper);
  font: 500 19px/1.3 var(--pixel);
  font-variant-ligatures: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
.px { image-rendering: pixelated; }

/* Heads-up bar: always one row (the strips below open under it). From left: the shop name (or,
   framed, the full-screen button), the stats, the patience and sound buttons, Regulars, the tutor. */
.hud {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px 20px;
  padding: 8px 16px;
  background: var(--night);
}
/* The name takes what the bar leaves: on two lines when one is too short, and its text never
   widens the page (contain), ending in an ellipsis before that. */
.brand {
  contain: inline-size;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  font: 700 clamp(18px, 2.2vw, 28px)/1.1 var(--pixel);
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--rust);
  overflow: hidden;
}
.stats { display: flex; gap: 18px; margin: 0; }
.stats div { display: grid; text-align: right; }
.stats dt { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--steel); white-space: nowrap; }
.stats dd { margin: 0; font: 32px/0.9 var(--digits); color: var(--yellow); white-space: nowrap; }
.stats dd small { font-size: .7em; } /* the streak's multiplier */
/* The day's pace, a chip beside the score's label (Chill blue, Monster orange) */
.stats dt[data-pace]:not([data-pace=""])::after { content: attr(data-pace); margin-left: 5px; padding: 0 4px; background: var(--chip, var(--steel)); color: var(--night); }
.stats dt[data-tilt="-1"] { --chip: var(--sky); }
.stats dt[data-tilt="1"] { --chip: var(--orange); }
.icon-btn { padding: 2px 6px; border: 0; background: none; color: var(--pink); font-size: 24px; line-height: 1; }
.icon-btn:is([data-act="tutor"], [data-act="fullscreen"]) { color: var(--steel); }
.icon-btn svg { display: block; image-rendering: pixelated; }
/* Full screen: expand corners to enter, inward corners to leave (main.js swaps the label) */
.icon-btn .exit, :root:fullscreen .icon-btn .enter { display: none; }
:root:fullscreen .icon-btn .exit { display: inline; }
.icon-btn:hover { filter: brightness(1.3); }
/* Framed in another page: its heading and the shop sign carry the name; full screen takes the name's place */
.framed .brand { display: none; }
.framed .hud .icon-btn[data-act="regulars"] { margin-left: auto; }

/* The top bar's strips (strip.js): a button in the bar, an icon and its value in VT323 like the
   stats, opens a strip of choices under the bar, headed by its aria-label, the chosen one in yellow.
   One is open at a time. Patience (an hourglass and the speed; no sand when off) and sound (a
   speaker and the volume; a cross when off) use it. */
.strip { display: flex; }
.strip[hidden] { display: none; }
.strip-now { display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px; border: 0; background: none; color: var(--steel); }
.strip-now svg { display: block; image-rendering: pixelated; }
.strip-now .value { font: 28px/0.9 var(--digits); color: var(--yellow); white-space: nowrap; }
.strip.off .strip-now .value { color: var(--steel); }
.strip-now:hover { filter: brightness(1.3); }
.strip.open .strip-now { background: var(--dusk); }
.strip-choices {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0 2ch;
  padding: 2px 16px 4px;
  background: var(--night);
  border-top: 2px solid var(--dusk);
  box-shadow: 0 3px 0 var(--night);
}
.strip.open .strip-choices { display: flex; }
.strip-choices::before { content: attr(aria-label); margin-right: auto; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--steel); }
.strip-choices button { min-height: 40px; padding: 0 2px; border: 0; background: none; color: var(--steel); font-size: 19px; }
.strip-choices button:hover { color: var(--paper); }
.strip-choices [aria-pressed="true"], .strip-choices [aria-checked="true"] b { color: var(--yellow); }
.strip-choices b { font-weight: inherit; }
.strip button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 1px; }
.patience-now .sand { fill: var(--amber); }
.patience.off .patience-now .sand { display: none; }
.patience-choices button { font: 28px/1 var(--digits); }
.sound-now .waves { fill: var(--amber); }
.sound-now .mute { display: none; fill: var(--steel); }
.sound.off .sound-now .waves { display: none; }
.sound.off .sound-now .mute { display: inline; }
.sound-choices .volumes { display: flex; gap: 0 2ch; }

/* Narrower than a laptop (an iPad, either way up): the shop sign in the scene carries the name, so the
   bar's name gives way and its gaps tighten before anything wraps. */
@media (max-width: 1000px) {
  .brand { display: none; }
  .hud { gap: 6px 12px; }
  .hud .icon-btn[data-act="regulars"] { margin-left: auto; }
}
/* Phones, small frames, split screens and phones on their side (760px wide or less; the bar's own
   breakpoint, wider than the layout's 480px, since the full bar needs about 720px): one slim row.
   The strip buttons show their icon alone (the icon still tells off from on; the strip names the
   choice), the stats' labels shrink and their digits scale with the width (still VT323, never
   under 18px), and the gaps close up. */
@media (max-width: 760px) {
  .hud { gap: 2px; min-height: 40px; padding: 3px 4px; }
  .stats { flex: 1; justify-content: space-evenly; gap: 2px; min-width: 0; }
  .stats div { text-align: center; }
  .stats dt { font-size: clamp(9px, 3.2vw, 10px); font-size: clamp(9px, round(down, 3.2vw, 1px), 10px); line-height: 1.1; letter-spacing: .02em; }
  .stats dd { font-size: clamp(18px, 5.8vw, 22px); font-size: clamp(18px, round(down, 5.8vw, 1px), 22px); }
  .stats dt[data-pace]:not([data-pace=""])::after { margin-left: 2px; padding: 0 2px; }
  .icon-btn { padding: 2px; font-size: 20px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .hud .icon-btn[data-act="regulars"] { margin-left: 0; }
  .strip-now { padding: 2px; }
  .strip-now .value { display: none; }
  .patience-now svg { width: 11px; height: 14px; }
  .sound-now svg { width: 14px; height: 14px; }
  .strip-choices { justify-content: space-between; gap: 0 1ch; padding: 2px 8px; }
  .strip-choices::before { flex-basis: 100%; font-size: 10px; }
  .strip-choices button { font-size: 16px; }
  .patience-choices button { font-size: 24px; }
  .sound-choices { justify-content: flex-start; }
  .sound-choices, .sound-choices .volumes { gap: 0 1ch; }
}
/* The narrowest frames (down to 254px): the score's label gives way to the pace chip, the digits
   may go down to 15px (still VT323) and the buttons' padding closes up. */
@media (max-width: 340px) {
  .stats dt[data-pace]:not([data-pace=""]) { font-size: 0; }
  .stats dt[data-pace]:not([data-pace=""])::after { margin: 0; font-size: 9px; }
  .hud { gap: 1px; padding: 3px 2px; }
  .stats { gap: 1px; }
  .stats dd { font-size: clamp(15px, 5.8vw, 18px); font-size: clamp(15px, round(down, 5.8vw, 1px), 18px); }
  .icon-btn, .strip-now { padding: 2px 1px; }
}

/* Scene beside the panel; stacked when the screen is tall */
main { display: grid; grid-template-columns: minmax(0, 1fr) clamp(330px, 32vw, 440px); min-height: 0; }
.scene { position: relative; min-height: 0; overflow: hidden; background: var(--sky); }
.world { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
.panel { display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 14px 16px; overflow-y: auto; }
@media (max-aspect-ratio: 1/1), (max-width: 760px) {
  main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(180px, 1fr) minmax(0, auto); }
  .panel { justify-content: flex-start; }
}

/* Words on top of the world, sized in world pixels (--u) */
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay > * { position: absolute; margin: 0; }
.sign {
  transform: translate(-50%, -50%);
  font: 700 calc(var(--u) * 4.4)/1.05 var(--pixel);
  color: var(--night);
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}
.bubble {
  transform: translateY(-100%);
  width: max-content;
  max-width: calc(var(--u) * 96);
  padding: .35em .6em;
  border: var(--edge);
  background: #fff;
  color: var(--night);
  font: 600 clamp(15px, calc(var(--u) * 4.8), 24px)/1.25 var(--pixel);
  box-shadow: 3px 3px 0 var(--night);
}
.bubble.box { transform: none; max-width: none; } /* the dialogue box along the scene's top (scene.js) */
.bubble::after {
  content: "";
  position: absolute;
  left: var(--tail, 18px);
  top: 100%;
  border: 8px solid transparent;
  border-top-color: var(--night);
  border-left-color: var(--night);
}
.tags { inset: 0; }
.tag {
  position: absolute;
  transform: translateX(-50%);
  width: calc(var(--u) * 29);
  margin: 0;
  padding: calc(var(--u) * 1) 2px;
  border: 2px solid var(--night);
  background: var(--paper);
  color: var(--night);
  text-align: center;
  box-shadow: 2px 2px 0 var(--night);
}
.tag::before { content: ""; position: absolute; left: 50%; bottom: 100%; width: 2px; height: calc(var(--u) * 2); background: var(--cream); }
.tag img { display: block; width: calc(var(--u) * 14); height: auto; margin: 0 auto; image-rendering: pixelated; }
.tag figcaption { font: 700 clamp(10px, calc(var(--u) * 3.6), 16px)/1.05 var(--pixel); }
.tag b { display: block; font: clamp(16px, calc(var(--u) * 6.5), 32px)/1 var(--digits); }
.till {
  width: calc(var(--u) * 33);
  padding: 0 calc(var(--u) * 1.5);
  border: 2px solid var(--night);
  background: var(--deep);
  color: var(--lime);
  font: clamp(15px, calc(var(--u) * 7), 34px)/1.15 var(--digits);
  text-align: right;
  box-shadow: 0 calc(var(--u) * 2) 0 var(--slate);
}
.cash {
  padding: 0 .4em;
  border: 2px solid var(--night);
  background: var(--lime);
  color: var(--night);
  font: clamp(16px, calc(var(--u) * 6.5), 32px)/1.1 var(--digits);
  transform: rotate(-6deg);
  box-shadow: 2px 2px 0 var(--night);
}

/* Today's line-up */
.lineup { display: grid; grid-template-columns: repeat(8, minmax(0, 64px)); justify-content: center; gap: 5px; }
.lineup button {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  padding: 3px;
  border: 2px solid var(--night);
  background: var(--dusk);
}
.lineup img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.lineup button:hover { background: var(--slate); }
.lineup .current { background: var(--yellow); box-shadow: 0 0 0 2px var(--yellow); }
.lineup .current:hover { background: var(--yellow); }
.lineup :is(.first, .second, .missed)::after {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 16px;
  height: 16px;
  border: 2px solid var(--night);
  font: 700 11px/12px var(--pixel);
  color: var(--night);
}
.lineup .first::after { content: "✓"; background: var(--lime); }
.lineup .second::after { content: "✓"; background: var(--amber); }
.lineup .missed::after { content: "•"; background: var(--steel); }

/* Cards */
.card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: var(--edge);
  background: var(--paper);
  color: var(--night);
  box-shadow: 5px 5px 0 var(--night);
}
.card h2 { margin: 0; font: 700 28px/1.1 var(--pixel); }
.card p { margin: 0; }
.sub { color: var(--slate); }
.who { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who b {
  padding: 1px 8px;
  border: 2px solid var(--night);
  background: var(--tag, var(--slate));
  color: var(--ink, #fff); /* night or white, whichever reads on the tag (main.js) */
}
.hearts { color: var(--pink); letter-spacing: 1px; }
.hearts i { color: #d9cfe0; font-style: normal; }

/* ===== The day's pace (main.js, game/shop.xml <difficulty>): one big button per pace opens the
   day, the last one picked in orange; easier ones lean blue, harder ones rust. Side by side where
   the names fit, else one under another. While the day runs its name sits beside the score; at
   closing time it's a tile of the tally. ===== */
.paces { display: grid; gap: 6px; container: paces / inline-size; }
.paces > p { font-weight: 700; }
.paces > div { display: grid; gap: 8px; }
.paces .pace { display: flex; align-items: baseline; justify-content: space-between; gap: 2px 10px; padding: 5px 10px; text-align: left; }
.paces .pace b { font-size: clamp(17px, 8cqi, 23px); font-size: clamp(17px, round(down, 8cqi, 1px), 23px); line-height: 1.1; }
.pace small { font-size: 13px; line-height: 1.15; text-align: right; white-space: nowrap; }
.pace small i { display: none; font-style: normal; }
.pace.quiet[data-tilt="-1"] b { color: var(--blue); }
.pace.quiet[data-tilt="1"] b { color: var(--rust); }
@container paces (min-width: 300px) {
  .paces > div { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .paces .pace { flex-direction: column; align-items: center; justify-content: center; padding: 10px 4px; text-align: center; }
  .paces .pace b { font-size: clamp(14px, 5.4cqi, 22px); font-size: clamp(14px, round(down, 5.4cqi, 1px), 22px); }
  .pace small { text-align: center; white-space: normal; }
  .pace small i { display: inline; }
}
.tally > div:last-child:nth-child(odd) { grid-column: 1 / -1; } /* an odd tile out spans the row */
@media (max-width: 480px) {
  .paces > div { gap: 6px; }
  .pace small { font-size: 11px; }
}

.receipt table { width: 100%; border-collapse: collapse; font-size: 19px; }
.receipt td { padding: 3px 0; border-bottom: 2px dashed var(--cream); }
.receipt td:first-child { display: flex; align-items: center; gap: 8px; }
.receipt td:last-child { padding-left: 10px; text-align: right; font: 30px/1 var(--digits); white-space: nowrap; }
.receipt .icon { width: 32px; flex: none; }

.step { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; }
.field { display: flex; align-items: center; gap: 4px; font: 34px var(--digits); }
.field input {
  width: 6ch;
  padding: 2px 8px;
  border: var(--edge);
  background: #fff;
  color: var(--night);
  font: 36px/1 var(--digits);
  text-align: right;
}
.field input:focus { outline: 3px solid var(--orange); outline-offset: 1px; }
.field input:disabled { border-color: var(--cream); background: transparent; color: var(--slate); }
.hint { min-height: 1.3em; color: var(--plum); font-weight: 700; }
.hint.good { color: var(--green); }
.shake { animation: shake .35s steps(4); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.go, .quiet {
  border: var(--edge);
  font-weight: 700;
  text-align: center;
}
.go {
  padding: 10px 16px;
  background: var(--orange);
  color: #fff;
  font-size: 23px;
  text-shadow: 2px 2px 0 var(--rust);
  box-shadow: 4px 4px 0 var(--night);
}
.quiet { padding: 7px 12px; background: var(--cream); color: var(--night); box-shadow: 3px 3px 0 var(--night); }
.go:hover, .quiet:hover { filter: brightness(1.08); }
.go:active, .quiet:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--night); }
/* A pressed button shifts 2px; this margin keeps the pointer on it, or a click near its edge is lost */
.go, .quiet { position: relative; }
.go:active::before, .quiet:active::before { content: ""; position: absolute; inset: -4px; }
.go:focus-visible, .quiet:focus-visible, .lineup button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > * { flex: 1; }

.big { font: 56px/1 var(--digits); color: var(--green); }
.points { font-weight: 700; }
.heart-up { color: var(--magenta); font-weight: 700; }
.mascot { display: flex; align-items: center; gap: 10px; }
.mascot img { width: 72px; flex: none; image-rendering: pixelated; }
.mascot p { font-weight: 700; }
.work {
  margin: 0;
  padding: 8px 14px;
  border: 2px solid var(--cream);
  background: #fff;
  font: 34px/1.05 var(--digits);
  overflow-x: auto;
}
.tally { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.tally div { padding: 6px 10px; border: 2px solid var(--night); background: #fff; }
.tally dt { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate); }
.tally dd { margin: 0; font: 34px/1 var(--digits); }

/* Place-value colours: the colour sits on the relevant detail, the column */
.place-colors .v2 { color: var(--plum); }
.place-colors .v1 { color: var(--blue); }
.place-colors .v0 { color: var(--green); }
.place-colors .v-1 { color: var(--magenta); }
.place-colors .v-2 { color: var(--rust); }
.place-colors .v-3 { color: var(--brown); }
.place-colors .pt { color: var(--orange); font-weight: 700; }

.note { display: grid; gap: 6px; font-weight: 700; }
textarea { width: 100%; padding: 8px 10px; border: var(--edge); font: 19px var(--pixel); resize: vertical; }

/* Dialogs */
dialog { padding: 0; border: 0; background: none; color: inherit; }
dialog::backdrop { background: #181425cc; }
#tutor .card { width: min(420px, calc(100vw - 32px)); max-height: 90vh; overflow-y: auto; }
#tutor fieldset { display: grid; gap: 8px; margin: 0; padding: 8px 10px 10px; border: 2px dashed var(--cream); }
#tutor legend { padding: 0 4px; font-weight: 700; }
#tutor input[name=token] { padding: 6px 8px; border: var(--edge); font: 17px var(--pixel); }
.report { margin: 0; padding-left: 20px; }
.slips { width: 100%; border-collapse: collapse; font-size: 16px; }
.slips th { text-align: left; color: var(--slate); font-weight: 700; }
.slips td, .slips th { padding: 2px 6px 2px 0; border-bottom: 2px dashed var(--cream); }
.slips td { font: 22px/1 var(--digits); }
.file { cursor: pointer; }
#regulars form { width: min(960px, 94vw); max-height: 88vh; overflow: auto; padding: 16px; border: var(--edge); background: var(--navy); box-shadow: 6px 6px 0 var(--night); }
#regulars header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
#regulars h2 { margin: 0; font: 700 28px var(--pixel); color: var(--yellow); text-shadow: 2px 2px 0 var(--rust); }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.regular { display: flex; gap: 12px; padding: 12px; border: var(--edge); background: var(--paper); color: var(--night); }
.regular .figure { height: 120px; max-width: 120px; object-fit: contain; object-position: bottom; flex: none; }
.regular h3 { margin: 0 0 2px; font: 700 22px var(--pixel); }
.regular ul { margin: 6px 0 0; padding-left: 18px; font-size: 17px; }
.regular .locked { color: var(--steel); }
.regular .locked span { color: var(--pink); }
.unknown .figure { filter: brightness(0) opacity(.75); }

/* Task steps beyond one number (main.js): a line of math on the card, big choice buttons, an
   expression with sign keys, and signs to tap into gaps. A step done gets a green tick; the choice
   that was right turns green, one tried and wrong goes slate. */
.sum { margin: 0; font: 34px/1.15 var(--digits); text-align: center; overflow-wrap: anywhere; }
.step.done > :first-child::after { content: " ✓"; color: var(--green); }
.step:is(.choice, .gaps, .expression) { display: grid; justify-content: stretch; gap: 6px; }
.receipt .step[hidden] { display: none; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(7em, 1fr)); gap: 8px; }
.choices.long { grid-template-columns: minmax(0, 1fr); } /* whole lines of math, one under another */
.pick, .keys button, .gap { border: var(--edge); background: #fff; color: var(--night); box-shadow: 3px 3px 0 var(--night); }
.pick { padding: 6px 10px; font: 28px/1.1 var(--digits); }
.pick:not(:disabled):hover, .keys button:hover, .gap:not(:disabled):hover { background: var(--paper); }
.pick:not(:disabled):active, .keys button:active, .gap:not(:disabled):active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--night); }
.pick:disabled, .gap:disabled { cursor: default; box-shadow: none; }
.pick:disabled { border-color: var(--cream); background: transparent; color: var(--slate); } /* not yet, or done */
.pick.chosen { border-color: var(--green); background: #e3f4dc; color: var(--night); }
.pick.tried { text-decoration: line-through; }
.done .pick:not(.chosen) { opacity: .45; }
.pick:focus-visible, .keys button:focus-visible, .gap:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.expression input {
  width: 100%;
  min-width: 0;
  padding: 2px 8px;
  border: var(--edge);
  background: #fff;
  color: var(--night);
  font: 32px/1 var(--digits);
}
.expression input:focus { outline: 3px solid var(--orange); outline-offset: 1px; }
.expression input:disabled { border-color: var(--cream); background: transparent; color: var(--slate); }
.keys { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.keys button { padding: 1px 0; font: 30px/1 var(--digits); box-shadow: 2px 2px 0 var(--night); }
.done .keys, .expression input:disabled + .keys { display: none; }
.gap { min-width: 1.4em; margin: 0 4px; padding: 0 6px; font: inherit; color: var(--orange); }
.gap:disabled { border-color: var(--cream); background: transparent; color: var(--night); }
.big.long { font-size: 34px; overflow-wrap: anywhere; }
.till { white-space: nowrap; }
/* A fraction stands stacked, as in class: numerator over a bar over denominator. */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .85em; line-height: 1; margin: 0 .08em; }
.till .frac { font-size: 1em; line-height: .9; } /* the till's type is already small */
.frac > span:first-child { border-bottom: max(2px, .08em) solid currentColor; padding: 0 .12em; } /* a scale's reading on the till's screen stays on one line (scene.js widens the till) */
/* A repeating digit wears a bar on top, as class writes it: 0.3 with a bar is 0.333... */
.bar { text-decoration: overline; text-decoration-thickness: max(2px, .07em); }
/* Tags to put in order: each placed tag shows its place in line (1, 2, 3) in an orange badge. */
.order .pick { position: relative; }
.order .pick.placed { border-color: var(--orange); background: var(--paper); }
.order .place { position: absolute; top: -12px; left: -12px; min-width: 26px; padding: 0 4px; border: 2px solid var(--night); border-radius: 13px; background: var(--orange); color: #fff; font: normal 22px/22px var(--digits); }
.order .place:empty { display: none; }

/* Phones and small frames: the stacked layout at 480px wide or less, from a 254px frame up.
   The top bar is one slim row; the shop sign in the scene carries the name. The card's type and
   spacing scale with the width (cqi), capped at the sizes above and rounded down to whole pixels
   so the pixel fonts stay crisp (each line without round() is the fallback for older browsers).
   The scene's speech becomes a dialogue box along its top (--talk, read by scene.js). */
@media (max-width: 480px) {
  .scene { --talk: box; }
  main { container-type: inline-size; }
  .panel {
    gap: clamp(8px, 3.4cqi, 12px); gap: clamp(8px, round(down, 3.4cqi, 1px), 12px);
    padding: clamp(8px, 3.4cqi, 14px) clamp(8px, 4cqi, 16px);
    padding: clamp(8px, round(down, 3.4cqi, 1px), 14px) clamp(8px, round(down, 4cqi, 1px), 16px);
    font-size: clamp(13px, 5cqi, 19px); font-size: clamp(13px, round(down, 5cqi, 1px), 19px);
  }
  .card {
    gap: clamp(6px, 2.7cqi, 10px); gap: clamp(6px, round(down, 2.7cqi, 1px), 10px);
    padding: clamp(8px, 3.4cqi, 14px) clamp(10px, 4cqi, 16px);
    padding: clamp(8px, round(down, 3.4cqi, 1px), 14px) clamp(10px, round(down, 4cqi, 1px), 16px);
  }
  .card h2 { font-size: clamp(17px, 6.7cqi, 28px); font-size: clamp(17px, round(down, 6.7cqi, 1px), 28px); }
  .lineup { gap: clamp(2px, 1.3cqi, 5px); gap: clamp(2px, round(down, 1.3cqi, 1px), 5px); }
  .who b { padding: 0 6px; }
  .receipt table, .slips, textarea { font-size: 1em; }
  .receipt td:first-child { gap: 6px; }
  .receipt td:last-child { font-size: clamp(18px, 7.4cqi, 30px); font-size: clamp(18px, round(down, 7.4cqi, 1px), 30px); }
  .receipt .icon { width: clamp(20px, 8cqi, 32px); width: clamp(20px, round(down, 8cqi, 1px), 32px); }
  .step { gap: 8px; }
  .field { font-size: clamp(20px, 7.4cqi, 34px); font-size: clamp(20px, round(down, 7.4cqi, 1px), 34px); }
  .field input { padding: 2px 6px; font-size: clamp(20px, 8cqi, 36px); font-size: clamp(20px, round(down, 8cqi, 1px), 36px); }
  .go {
    padding: clamp(6px, 2.7cqi, 10px) clamp(10px, 4cqi, 16px);
    padding: clamp(6px, round(down, 2.7cqi, 1px), 10px) clamp(10px, round(down, 4cqi, 1px), 16px);
    font-size: clamp(15px, 5.7cqi, 23px); font-size: clamp(15px, round(down, 5.7cqi, 1px), 23px);
  }
  .quiet { padding: 5px 8px; }
  .row { gap: 8px; }
  .big { font-size: clamp(36px, 13.4cqi, 56px); font-size: clamp(36px, round(down, 13.4cqi, 1px), 56px); }
  .work { padding: 6px 10px; font-size: clamp(20px, 8cqi, 34px); font-size: clamp(20px, round(down, 8cqi, 1px), 34px); }
  .mascot img { width: clamp(44px, 18cqi, 72px); width: clamp(44px, round(down, 18cqi, 1px), 72px); }
  .tally { gap: 6px; }
  .tally div { padding: 4px 8px; }
  .tally dt { font-size: 11px; }
  .tally dd { font-size: clamp(22px, 8cqi, 34px); font-size: clamp(22px, round(down, 8cqi, 1px), 34px); }
  .slips td { font-size: clamp(16px, 6cqi, 22px); font-size: clamp(16px, round(down, 6cqi, 1px), 22px); }

  #regulars { max-width: none; }
  #regulars form { width: calc(100vw - 16px); padding: 10px; }
  #regulars h2 { font-size: 22px; }
  .board { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .regular { gap: 8px; padding: 8px; }
  .regular .figure { height: 84px; max-width: 84px; }
  .regular h3 { font-size: 18px; }
  .regular ul { padding-left: 16px; font-size: 14px; }

  /* Task steps. A card with several steps gets a little more of the screen (the world is drawn at
     its smallest scale here either way) and keeps its receipt rows to one line where it can. */
  main:has(.receipt.steps) { grid-template-rows: minmax(150px, 1fr) minmax(0, auto); }
  .receipt.steps td { padding: 2px 0; }
  .receipt.steps td:first-child { line-height: 1.15; }
  .receipt.steps td:last-child { font-size: clamp(16px, 6cqi, 30px); font-size: clamp(16px, round(down, 6cqi, 1px), 30px); }
  .sum { font-size: clamp(20px, 7.4cqi, 34px); font-size: clamp(20px, round(down, 7.4cqi, 1px), 34px); }
  .choices { gap: 6px; }
  .pick { padding: 4px 8px; font-size: clamp(18px, 6.7cqi, 28px); font-size: clamp(18px, round(down, 6.7cqi, 1px), 28px); }
  .expression input { padding: 2px 6px; font-size: clamp(20px, 8cqi, 32px); font-size: clamp(20px, round(down, 8cqi, 1px), 32px); }
  .keys { gap: 4px; }
  .keys button { font-size: clamp(18px, 6.4cqi, 30px); font-size: clamp(18px, round(down, 6.4cqi, 1px), 30px); }
  .gap { margin: 0 2px; padding: 0 4px; }
  .big.long { font-size: clamp(22px, 8cqi, 34px); font-size: clamp(22px, round(down, 8cqi, 1px), 34px); }
}

/* ===== Calendar and clock (main.js, scene.js): the date on the start and closing cards, and the
   clock on the dock's front, a little face with the time of day and the date. It shows how far
   the day has come by customers served, never a countdown. ===== */
.clock {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 1.5);
  padding: calc(var(--u) * 1) calc(var(--u) * 2) calc(var(--u) * 1) calc(var(--u) * 1);
  border: 2px solid var(--night);
  background: var(--brown);
  color: var(--cream);
  box-shadow: 2px 2px 0 var(--night);
}
.clock[hidden] { display: none; }
.clock .face { flex: none; width: max(calc(var(--u) * 13), 26px); image-rendering: pixelated; }
.clock .when { display: grid; margin: 0; }
.clock .date { font: 700 clamp(11px, calc(var(--u) * 3.2), 15px)/1.1 var(--pixel); white-space: nowrap; }
.clock .time { font: 400 clamp(16px, calc(var(--u) * 6), 30px)/.9 var(--digits); color: var(--yellow); white-space: nowrap; }
.clock.short .date { display: none; }

.date-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 10px; }
.date-line b { font-weight: 700; }
.date-line span { color: var(--slate); font-size: .85em; }
.date-line i { font-style: normal; color: var(--green); font-weight: 700; }
/* Small and short (a phone, or the framed copy): the card's heading already asks, so the paces drop their label */
@media (max-width: 480px) and (max-height: 700px) { .paces > p { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

/* ===== Saves (main.js): the "Choose your save" screen, the start card's save tag, and the
   tutor menu's save tools. Like a console's save files: one card per save, the last one played
   in yellow, a number tile, the name and what the save holds. ===== */

/* No save open yet: the top bar's numbers and the Regulars button wait for one */
.choosing .hud :is(.stats, .patience, [data-act="regulars"]) { visibility: hidden; }

.save-list { display: grid; gap: 10px; }
.save {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 12px;
  padding: 8px 12px 8px 8px;
  border: var(--edge);
  background: #fff;
  color: var(--night);
  text-align: left;
  box-shadow: 3px 3px 0 var(--night);
}
.save .num {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 44px;
  aspect-ratio: 1;
  border: 2px solid var(--night);
  background: var(--dusk);
  color: var(--yellow);
  font: 36px/1 var(--digits);
}
.save b { min-width: 0; font-size: 22px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save .facts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate); }
.save .facts i { font: normal 22px/1 var(--digits); letter-spacing: 0; color: var(--night); }
.save.empty b { color: var(--slate); }
.save.last { background: var(--yellow); }
.save.last .num { background: var(--orange); color: #fff; text-shadow: 2px 2px 0 var(--rust); }
.save:hover { filter: brightness(1.05); }
.save:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--night); }
.save:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.synced { font-size: 15px; }
.synced:empty { display: none; }

/* The start card's save tag, which is also the way back to the save screen */
.save-tag {
  justify-self: start;
  display: flex;
  max-width: 100%;
  padding: 0;
  border: 2px solid var(--night);
  background: var(--dusk);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--night);
}
.save-tag span { min-width: 0; padding: 1px 8px; color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-tag i { flex: none; padding: 1px 8px; border-left: 2px solid var(--night); background: var(--cream); color: var(--night); font-style: normal; }
.save-tag:hover { filter: brightness(1.08); }
.save-tag:active { transform: translate(2px, 2px); box-shadow: none; }
.save-tag:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.naming input { width: 100%; padding: 6px 10px; border: var(--edge); background: #fff; color: var(--night); font: 22px var(--pixel); }
.naming input:focus { outline: 3px solid var(--orange); outline-offset: 1px; }

/* Tutor menu: clearing takes two steps; the second says what goes */
#tutor [hidden] { display: none; }
#tutor .row.this-save > * { flex: 1 1 auto; white-space: nowrap; }
.clearing, .confirm { display: grid; gap: 8px; }
.confirm { padding: 8px 10px; border: 2px solid var(--plum); background: #fff; }
.confirm p { font-size: 16px; }
.quiet.wipe { background: var(--plum); color: #fff; }
/* Tutor menu: the topic mix, a preset and, for a pick, a tick per unit */
#tutor .mix select { padding: 6px 8px; border: var(--edge); background: #fff; color: var(--night); font: 17px var(--pixel); }
#tutor .topics:not([hidden]) { display: grid; gap: 6px; }
.tick { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.tick input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--orange); }
#tutor .mix-note { font-size: 16px; }
.counted { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.counted input { width: 20px; height: 20px; margin: 0; accent-color: var(--orange); }

@media (max-width: 480px) {
  .save-list { gap: clamp(6px, 2.7cqi, 10px); gap: clamp(6px, round(down, 2.7cqi, 1px), 10px); }
  .save { gap: 0 8px; padding: 6px 8px 6px 6px; }
  .save .num {
    width: clamp(32px, 11cqi, 44px); width: clamp(32px, round(down, 11cqi, 1px), 44px);
    font-size: clamp(26px, 9cqi, 36px); font-size: clamp(26px, round(down, 9cqi, 1px), 36px);
  }
  .save b { font-size: clamp(16px, 5.7cqi, 22px); font-size: clamp(16px, round(down, 5.7cqi, 1px), 22px); }
  .save .facts { gap: 0 8px; font-size: 11px; }
  .save .facts i { font-size: clamp(17px, 6cqi, 22px); font-size: clamp(17px, round(down, 6cqi, 1px), 22px); }
  .synced, .save-tag { font-size: 13px; }
  .naming input { font-size: 19px; }
}

/* ===== Impatient customers (main.js, impatience.js): waiting customers' line-up buttons, and
   their nags along the top of the scene. (The patience button is a top-bar strip, above.) ===== */

/* A waiting customer's button warms up as they do; a nag wiggles it. */
.lineup .annoyed:not(.current) { background: var(--brown); }
.lineup .angry:not(.current) { background: var(--rust); }
.lineup .nags { animation: nag .5s steps(4) 2; }
@keyframes nag {
  25% { transform: translateY(-3px) rotate(-6deg); }
  75% { transform: translateY(-3px) rotate(6deg); }
}

/* The nag: who is waiting and what they say, in a box along the top of the scene (scene.js). */
.nag {
  display: flex;
  align-items: center;
  gap: .5em;
  padding: .3em .6em;
  border: var(--edge);
  background: #fff;
  color: var(--night);
  font: 600 clamp(15px, calc(var(--u) * 4.8), 24px)/1.25 var(--pixel);
  box-shadow: 3px 3px 0 var(--night);
}
.nag[hidden] { display: none; }
.nag img { flex: none; max-width: 3em; height: auto; image-rendering: pixelated; }

/* ===== Upgrades (main.js, game/upgrades.xml): the next one on the start and closing cards, gold
   when there's cash enough to buy it, and its card at closing time. ===== */
.upgrade-next { display: flex; align-items: center; gap: 4px 10px; text-align: left; }
.upgrade-next.sub { display: block; }
.upgrade-next img { flex: none; width: auto; max-width: 56px; height: 28px; object-fit: contain; }
.upgrade-next > span { flex: 1; }
.upgrade-next.ready { background: var(--yellow); }
.price { font-family: var(--digits); font-size: 1.35em; font-weight: 400; line-height: 1; white-space: nowrap; }
.next-up { display: flex; align-items: center; gap: 12px; }
.next-up .art { flex: none; width: auto; max-width: 42%; height: 76px; object-fit: contain; }
.next-up p { display: grid; gap: 2px; font-size: 19px; }
.next-up p > b:first-child { font-size: 22px; }
.next-up p > span { color: var(--slate); font-size: 16px; }
.unlocks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; font-size: 15px; font-weight: 700; }
.unlocks li { display: flex; align-items: center; gap: 4px; }
.unlocks .icon { width: 28px; height: auto; }
@media (max-width: 480px) {
  .next-up .art { height: 56px; }
  .next-up p { font-size: 17px; }
  .next-up p > b:first-child { font-size: 19px; }
  .next-up p > span { font-size: 14px; }
}
