:root {
  --ink: #1f2a24;
  --panel: rgba(16, 40, 36, 0.7);
  --green: #2f7d6d;
  --red: #b3261e;
  --gold: #ffd23f;
  --card: rgba(252, 255, 250, 0.96);
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe6f2; color: #fff; }
button, select, output, input { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }
svg { display: block; }
kbd {
  font: 700 0.85em/1 ui-monospace, monospace;
  padding: 0.15em 0.4em;
  border-radius: 0.3em;
  background: #e4efe9;
  border: 1px solid #b9cfc4;
  color: var(--ink);
}

/* ---------- Scene ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; }
#scene3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* Labels pinned to the 3D scene by js/scene.js (with the translate property) */
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.stock, .till, .bubble {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -100%);
  font-weight: 800; line-height: 1;
  white-space: nowrap;
}
.stock {
  min-width: 1.7em;
  padding: 0.12em 0.3em 0.02em;
  border-radius: 0.6em;
  background: #fff;
  color: var(--ink);
  font-size: 4.2vh;
  text-align: center;
  box-shadow: 0 0.4vh 1.2vh rgba(0, 0, 0, 0.3);
}
.stock.none { background: #ffd9d6; color: var(--red); }
.till {
  padding: 0.12em 0.4em 0.02em;
  border-radius: 0.5em;
  background: var(--gold);
  color: #4a3500;
  font-size: 4.2vh;
  box-shadow: 0 0.4vh 1.2vh rgba(0, 0, 0, 0.3);
}
.till.bump { animation: grow 0.35s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes grow { 0% { scale: 0.8; } 60% { scale: 1.2; } 100% { scale: 1; } }
.bubble {
  display: flex; align-items: center; gap: 0.3em;
  padding: 0.2em 0.45em;
  border-radius: 0.8em;
  background: #fff;
  color: var(--ink);
  font-size: 2.8vh;
  box-shadow: 0 0.4vh 1vh rgba(0, 0, 0, 0.25);
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -0.45em;
  border: 0.5em solid transparent; border-bottom: 0; border-top-color: #fff;
  transform: translateX(-50%);
}
.bubble svg { width: 1.8em; height: 1.8em; }
.bubble span:empty { display: none; }
.bubble.yes { color: #1d6b38; }
.bubble.no { background: #ffe1de; color: var(--red); }
.bubble.no::after { border-top-color: #ffe1de; }

/* ---------- Top: toolbar, day and task, money ---------- */
#hud-top {
  position: fixed; left: 0; right: 0; top: 0;
  display: flex; align-items: flex-start; gap: 2vw;
  padding: 2vh 2vw;
  z-index: 10;
  pointer-events: none;
}
#hud-top > * { pointer-events: auto; }
#toolbar { display: flex; gap: 0.5vw; flex: 0 0 auto; width: 22vh; }
#toolbar button {
  width: 5.4vh; height: 5.4vh;
  border-radius: 1.4vh;
  border: none;
  background: var(--panel);
  font-size: 2.8vh;
  cursor: pointer;
  color: #fff;
  display: grid; place-items: center;
}
#toolbar button:hover { background: rgba(16, 40, 36, 0.85); }

#board { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.8vh; }
#week-days { display: flex; gap: 0.6vh; margin: 0; padding: 0; list-style: none; }
#week-days li {
  padding: 0.1vh 1.4vh 0;
  border-radius: 1.2vh;
  background: var(--panel);
  font-size: 2.3vh; font-weight: 800;
  opacity: 0.7;
}
#week-days li.done { background: rgba(47, 125, 109, 0.85); opacity: 1; }
#week-days li.done::after { content: ' ✓'; }
#week-days li.today { background: var(--gold); color: var(--ink); opacity: 1; }
#task {
  text-align: center;
  font-weight: 800;
  line-height: 1.15;
  border-radius: 3vh;
  background: var(--panel);
  text-shadow: 0 0.25vh 0 rgba(0, 0, 0, 0.3);
  font-size: clamp(18px, 3.8vh, 56px);
  padding: 0.6vh 2.4vw;
  max-width: 62vw;
}
#task:empty { visibility: hidden; }
#task.pop { animation: pop 0.45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { from { transform: scale(0.85); opacity: 0.3; } to { transform: scale(1); opacity: 1; } }

#money {
  flex: 0 0 auto; width: 22vh;
  display: flex; flex-direction: column; align-items: flex-end;
  font-weight: 800;
}
#money span { font-size: 2.2vh; text-shadow: 0 0.2vh 0 rgba(0, 0, 0, 0.4); }
#money b {
  font-size: 5.6vh; line-height: 1;
  padding: 0.6vh 1.6vh 0.1vh;
  border-radius: 1.8vh;
  background: var(--gold); color: #4a3500;
  box-shadow: 0 0.5vh 0 #c99a12;
}
#money.bump b { animation: bump 0.8s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes bump { 0% { transform: scale(0.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* ---------- Morning ---------- */
#morning {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; align-items: stretch; gap: 1.2vw;
  padding: 0 2vw 2vh;
  z-index: 10;
}
.card {
  background: var(--card);
  color: var(--ink);
  border-radius: 2.4vh;
  padding: 1.2vh 1.4vh;
  box-shadow: 0 1vh 3vh rgba(0, 0, 0, 0.25);
}
#forecast { width: 21%; display: flex; flex-direction: column; gap: 0.4vh; }
#forecast h3 { margin: 0; font-size: 2.2vh; text-transform: uppercase; letter-spacing: 0.08em; color: #5a6b63; }
#forecast .weather { display: flex; align-items: center; gap: 1vh; }
#forecast .weather svg { width: 7vh; height: 7vh; }
#forecast .weather b { font-size: 4.4vh; line-height: 1; }
#forecast p { margin: 0; font-size: 2.3vh; line-height: 1.2; font-weight: 700; }
#forecast .event { background: #fff1c2; border-radius: 1.4vh; padding: 0.5vh 1vh; font-size: 2vh; line-height: 1.2; }
#forecast .event b { display: block; font-size: 2.4vh; color: #8a5a00; }
#forecast small { margin-top: auto; font-size: 1.8vh; color: #5a6b63; line-height: 1.2; }

#make { flex: 1; display: flex; gap: 1.2vw; }
.item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.6vh; }
.item-head { display: flex; align-items: center; gap: 0.8vh; }
.item-head svg { width: 5.6vh; height: 5.6vh; }
.item-head b { font-size: 3.8vh; line-height: 1; }
.prices { font-size: 2.1vh; color: #3f5249; text-align: center; }
.prices b { color: var(--ink); }
.stepper { display: flex; align-items: center; gap: 1.2vh; }
.stepper button {
  width: 8.4vh; height: 8.4vh;
  border: none; border-radius: 2vh;
  font-size: 6vh; font-weight: 800; line-height: 1;
  cursor: pointer;
  color: #fff;
}
.stepper .plus { background: var(--green); box-shadow: 0 0.6vh 0 #1d5248; }
.stepper .minus { background: #c0553c; box-shadow: 0 0.6vh 0 #8a3523; }
.stepper button:active { transform: translateY(0.5vh); box-shadow: none; }
.stepper button:disabled { opacity: 0.3; cursor: default; transform: none; }
.stepper output { min-width: 2.2ch; text-align: center; font-size: 7vh; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.item .sum { font-size: 3vh; font-weight: 800; font-variant-numeric: tabular-nums; }
.item .kept { font-size: 2vh; font-weight: 700; color: #6b5200; min-height: 2.4vh; text-align: center; line-height: 1.1; }

#budget { width: 19%; display: flex; flex-direction: column; gap: 0.3vh; }
#budget .line { display: flex; justify-content: space-between; align-items: baseline; font-size: 2.5vh; font-weight: 700; }
#budget .line b { font-size: 3.4vh; font-variant-numeric: tabular-nums; }
#budget .line.left { border-top: 0.3vh solid #cfe0d7; padding-top: 0.3vh; }
#budget .line.left b { font-size: 5.4vh; color: var(--green); line-height: 1; }
.go {
  margin-top: auto;
  height: 8vh;
  border: none; border-radius: 2vh;
  background: #5fd068; color: #0e3a1a;
  font-size: 3.4vh; font-weight: 800;
  box-shadow: 0 0.6vh 0 #2f8f3a;
  cursor: pointer;
}
.go:active { transform: translateY(0.5vh); box-shadow: none; }

/* ---------- During the day ---------- */
#daybar {
  position: fixed; left: 2vw; right: 2vw; bottom: 2vh;
  display: flex; align-items: center; gap: 1.4vw;
  padding: 1vh 1.4vh;
  border-radius: 2.4vh;
  background: var(--panel);
  z-index: 10;
}
#tally { display: flex; gap: 1.4vw; }
#tally > div { display: flex; align-items: center; gap: 0.8vh; font-size: 2.3vh; line-height: 1.05; }
#tally svg { width: 5.6vh; height: 5.6vh; }
#tally b { font-size: 3vh; }
#tally .out span b:last-of-type { color: #ffb3ab; }
#customers { flex: 1; text-align: center; font-size: 3vh; font-weight: 800; }
#daybar button {
  height: 7vh; padding: 0 2.4vh;
  border: none; border-radius: 1.8vh;
  font-size: 2.8vh; font-weight: 800;
  cursor: pointer;
  background: #fff; color: var(--ink);
}
#faster[aria-pressed='true'] { background: var(--gold); }

/* ---------- End of a day and of the week ---------- */
#sheet {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 15;
  background: rgba(5, 16, 14, 0.45);
  padding: 13vh 2vw 2vh;
  overflow: auto;
}
#sheet .panel { width: min(1180px, 96vw); padding: 2.2vh 2.4vw 2vh; }
.sheet-title { display: flex; align-items: center; gap: 1vh; flex-wrap: wrap; margin: 0 0 1.2vh; font-size: 4.4vh; line-height: 1.1; color: var(--green); }
.sheet-title svg { width: 5.4vh; height: 5.4vh; }
.sheet-title small { font-size: 2.4vh; color: #5a6b63; font-weight: 700; }
.sums { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4vh 2vw; }
.sums section { background: #f1f7f3; border-radius: 1.8vh; padding: 1vh 1.6vh; }
.sums h3 { margin: 0 0 0.4vh; font-size: 2.4vh; color: #5a6b63; }
.sums ul { margin: 0; padding: 0; list-style: none; font-size: 3vh; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.sums .total { margin: 0.4vh 0 0; font-size: 3vh; font-weight: 800; color: var(--green); }
.sums .note { margin: 0.4vh 0 0; font-size: 2.3vh; font-weight: 700; color: #8a5a00; }
.sums .now { background: #fff3c4; }
.sums .big { margin: 0; font-size: 4.6vh; font-weight: 800; font-variant-numeric: tabular-nums; }
.sums .big b { color: var(--green); }

.week { display: grid; grid-template-columns: 1.15fr 1fr; gap: 2vw; align-items: start; }
.graph { width: 100%; height: auto; }
.graph .grid { stroke: #dfe9e4; stroke-width: 1.5; }
.graph .axis { font-size: 17px; font-weight: 700; fill: #5a6b63; }
.graph .value { font-size: 18px; font-weight: 800; fill: #fff; }
.graph .value.above { fill: var(--ink); }
.graph .bar { fill: var(--green); }
.graph .bar.start { fill: #9bb8ad; }
.graph .best { fill: none; stroke: #e0752d; stroke-width: 3.5; stroke-dasharray: 9 7; }
.graph .best-dot { fill: #e0752d; }
.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 0.8vh; margin: 0.6vh 0 0; font-size: 2vh; font-weight: 700; color: #3f5249; }
.key { display: inline-block; width: 2.6vh; height: 1.8vh; border-radius: 0.4vh; }
.key.bar { background: var(--green); }
.key.best { height: 0; border-top: 0.5vh dashed #e0752d; margin-left: 1.4vh; }
.results p { margin: 0 0 0.8vh; font-size: 2.6vh; line-height: 1.25; }
.results .big { font-size: 3.6vh; font-weight: 800; }
.results b { color: var(--green); }
.results table { border-collapse: collapse; font-size: 2.2vh; font-variant-numeric: tabular-nums; width: 100%; }
.results th, .results td { padding: 0.2vh 0.8vh; text-align: center; border-bottom: 1px solid #dfe9e4; }
.results td svg { width: 3.2vh; height: 3.2vh; margin: auto; }
.results .note { font-size: 1.9vh; color: #5a6b63; }

/* ---------- Setup menu ---------- */
#setup {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 20;
  background: radial-gradient(ellipse at center, rgba(10, 30, 26, 0.5), rgba(5, 16, 14, 0.85));
  overflow: auto;
  padding: 3vh 2vw;
}
.panel {
  width: min(900px, 94vw);
  background: rgba(252, 255, 250, 0.97);
  color: var(--ink);
  border-radius: 28px;
  padding: 26px 34px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.logo { margin: 0; font-size: 50px; line-height: 1; font-weight: 800; color: var(--red); letter-spacing: -0.5px; }
.tagline { margin: 8px 0 18px; font-size: 19px; line-height: 1.35; color: #3f5249; }
#setup h2 { margin: 0 0 8px; font-size: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 18px; }
.cards button {
  border: 3px solid #d5e3dc;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.cards button:hover { transform: translateY(-2px); }
.cards button[aria-pressed='true'] { border-color: var(--green); background: #eaf6f0; }
.cards b { display: block; font-size: 22px; line-height: 1.1; }
.cards span { display: block; font-size: 15px; color: #5a6b63; line-height: 1.3; }
#week-row { align-items: center; justify-content: space-between; margin-bottom: 14px; }
#week-status { margin: 0; font-size: 19px; font-weight: 700; }
#week-row label { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.code-entry { display: flex; gap: 8px; }
#code {
  width: 7.5ch;
  padding: 6px 10px;
  border-radius: 12px; border: 2px solid #cfe0d7;
  font-size: 24px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  text-align: center;
}
#use-code, .buttons button {
  border: 2px solid var(--green);
  background: #fff;
  color: var(--green);
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 18px; font-weight: 800;
  cursor: pointer;
}
#code-error { margin: -6px 0 12px; color: var(--red); font-weight: 700; }
.row { display: flex; gap: 18px; flex-wrap: wrap; }
.buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
#sheet .buttons { margin-top: 1.6vh; justify-content: flex-end; }
.buttons button.primary { background: var(--green); color: #fff; font-size: 22px; padding: 12px 34px; box-shadow: 0 6px 0 #1d5248; }
.buttons button.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #1d5248; }
#offline-status { margin: 10px 0 0; font-size: 15px; font-weight: 700; color: var(--green); }
.help { margin-top: 16px; font-size: 15px; color: #3f5249; }
.help summary { cursor: pointer; font-weight: 700; }
.help ul { padding-left: 20px; line-height: 1.5; }
