/* Nunito (SIL Open Font License), bundled so the app works with no internet */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("fonts/nunito-latin.woff2") format("woff2");
}

/* ============ Corner Shop theme: one warm, light palette ============ */
:root {
  --bg: #fff6e8;
  --surface: #ffffff;
  --surface-2: #fff1dc;   /* sand: trays, chips */
  --surface-3: #f6dfbd;   /* darker sand: till */
  --ink: #2d2219;
  --muted: #7b6a58;
  --line: #efdcc0;
  --line-strong: #e2c79f;

  --brand: #13a38b;       /* mint teal: primary actions */
  --brand-dark: #0d7d6a;
  --brand-soft: #d9f4ee;
  --flame: #ff8a3d;       /* streaks */
  --flame-dark: #d9661c;
  --gold: #ffc43d;        /* XP, stars */
  --gold-dark: #d9a01c;
  --berry: #7c5cd6;       /* chart line, level badge */

  --good: #22a45d;  --good-bg: #e3f6ea;
  --warn: #c97d0a;  --warn-bg: #fff1d6;
  --bad: #db4848;   --bad-bg: #fde6e6;

  --lcd-bg: #c9d9b0;      /* classic light calculator LCD */
  --lcd-ink: #1f2e17;

  /* names used by charts.js */
  --card: var(--surface);
  --accent: var(--berry);

  --radius: 18px;
  --chunk: 0 4px 0 var(--line);
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto;
  font-family: var(--font);
  font-weight: 600;
  background: var(--bg);
  background-image: radial-gradient(var(--line) 1px, transparent 1.5px);
  background-size: 22px 22px;
  color: var(--ink);
  padding: 10px 16px 24px;
  max-width: 1180px;
}
h1 { font-size: 1.4rem; font-weight: 900; margin: 0; white-space: nowrap; }
h2 { font-size: 1rem; font-weight: 800; margin: 0 0 8px; color: var(--muted); }
h2 small { font-weight: 700; color: var(--muted); margin-left: 6px; }
button, select { font: inherit; cursor: pointer; }
kbd {
  font: 800 .7em ui-monospace, Menlo, monospace;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: 4px;
  color: var(--ink);
}
.hidden { display: none !important; }

.card {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--chunk);
}

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800; color: var(--ink);
  background: var(--surface); box-shadow: 0 3px 0 var(--line-strong); border: 2px solid var(--line-strong);
  transition: transform .05s, box-shadow .05s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 transparent; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand-dark); box-shadow: 0 4px 0 var(--brand-dark); font-size: 1.08rem; padding: 11px 22px; }
.btn.primary kbd { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.4); color: #fff; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: .9rem; }
.btn.danger { background: var(--bad); color: #fff; border-color: #a83232; box-shadow: 0 3px 0 #a83232; }
.btn.danger:hover { filter: brightness(1.05); }
.btn.rush-btn { background: var(--gold); border-color: var(--gold-dark); box-shadow: 0 3px 0 var(--gold-dark); }

/* ---------- top bar ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.logo { display: inline-block; transform: rotate(-6deg); }
.tabs { margin-right: auto; }
.seg { display: flex; background: var(--surface); border: 2px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: var(--chunk); }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.seg button.active { background: var(--brand); color: #fff; }
.tabs button.active { background: var(--ink); }

/* ---------- profile strip ---------- */
.profile { display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 10px; flex-wrap: wrap; }
.level-badge {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--berry); color: #fff; font-weight: 900; font-size: 1.2rem; box-shadow: 0 3px 0 #5a3fb0; transform: rotate(-4deg);
}
.xp { flex: 1 1 200px; min-width: 160px; }
.xp-top { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 4px; }
.xp-top span { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 12px; background: var(--surface-2); border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar.small { height: 9px; border-width: 1px; }
.fill { height: 100%; width: 0; border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1), background-color .3s; }
.xp-fill { background: var(--gold); }
.goal-fill { background: var(--brand); }
.pill { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 12px; padding: 6px 10px; }
.pill b { font-size: 1.1rem; }
.pill small { color: var(--muted); }
.goal-body { min-width: 110px; }
.goal-body small { display: block; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.pill.goal.done { background: var(--brand-soft); }

/* ---------- HUD ---------- */
.play { display: flex; flex-direction: column; gap: 10px; }
.hudbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
body:not(.on-play) .hudbar { display: none; }
.emoji, .avatar, .pface, .logo, .ach .icon, .modal-card .big, .met-card .face {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}
.chip {
  display: flex; align-items: center; gap: 6px; background: var(--surface); border: 2px solid var(--line); border-radius: 12px;
  padding: 5px 12px; font-variant-numeric: tabular-nums; min-width: 84px; justify-content: center; box-shadow: 0 3px 0 var(--line);
}
.chip b { font-size: 1.15rem; font-weight: 900; }
.chip small { color: var(--flame-dark); font-weight: 900; }
.chip.flame.hot { background: var(--flame); border-color: var(--flame-dark); color: #fff; box-shadow: 0 3px 0 var(--flame-dark); }
.chip.flame.hot small { color: #fff; }
.chip.flame.blaze { animation: blaze 1s ease-in-out infinite alternate; }
@keyframes blaze { to { box-shadow: 0 3px 0 var(--flame-dark), 0 0 16px 2px rgba(255,138,61,.6); } }
.chip.rush { background: var(--gold); border-color: var(--gold-dark); box-shadow: 0 3px 0 var(--gold-dark); }
.chip.rush.low { background: var(--bad); border-color: #a83232; color: #fff; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

/* ---------- counter: customer + register ---------- */
.counter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr); gap: 14px; }
@media (max-width: 760px) { .counter { grid-template-columns: 1fr; } }

.customer { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  width: 84px; height: 84px; border-radius: 24px; display: grid; place-items: center; font-size: 3.3rem; flex: none;
  background: #ffe3c2; border: 2px solid var(--line-strong); box-shadow: 0 4px 0 var(--line-strong);
}
.avatar.enter { animation: enter .35s cubic-bezier(.2,.9,.3,1.3); }
@keyframes enter { from { transform: translateX(-30px) scale(.6); opacity: 0; } }
.avatar.happy { animation: hop .5s ease; }
@keyframes hop { 30% { transform: translateY(-14px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
.avatar.sad { animation: shake .4s; }
.customer-info { flex: 1; min-width: 0; }
.cname { font-weight: 900; font-size: 1.05rem; }
.bubble {
  position: relative; background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; margin-top: 6px;
  line-height: 1.3;
}
.bubble::before {
  content: ''; position: absolute; left: -9px; top: 12px; border: 8px solid transparent; border-right-color: var(--line); border-left: 0;
}
.bubble::after {
  content: ''; position: absolute; left: -6px; top: 13px; border: 7px solid transparent; border-right-color: var(--surface-2); border-left: 0;
}
.patience { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.patience .bar { flex: 1; }
.patience-fill { background: var(--good); transition: width .15s linear, background-color .3s; }

.register {
  background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  grid-template-areas: "item lcd" "plabel due" "money money";
}
.receipt-line { grid-area: item; font-weight: 800; font-size: 1.05rem; }
.lcd-row { grid-area: lcd; display: flex; align-items: center; gap: 8px; justify-self: end; }
.lcd-label { color: var(--muted); font-weight: 900; letter-spacing: .14em; font-size: .8rem; }
.lcd {
  background: var(--lcd-bg); color: var(--lcd-ink); font: 700 2.2rem ui-monospace, "Courier New", monospace;
  padding: 0 12px; border-radius: 8px; border: 2px solid #a9bd8c; box-shadow: inset 0 2px 0 rgba(0,0,0,.08);
  font-variant-numeric: tabular-nums;
}
.paid { display: contents; } /* its label and money sit on separate rows of the register grid */
.paid > .label { grid-area: plabel; }
.paid > .money-row { grid-area: money; }
.label { color: var(--muted); }
.label strong { color: var(--ink); font-size: 1.15rem; margin-left: 6px; font-weight: 900; }
/* the customer's money: big enough to count at a glance */
.paid .money-row { min-height: 0; gap: 10px; margin-top: 2px; }
.paid .bill img { width: 160px; }
.paid .coin.c1 img { width: 56px; height: 56px; }
.paid .coin.c5 img { width: 62px; height: 62px; }
.paid .coin.c10 img { width: 53px; height: 53px; }
.paid .coin.c25 img { width: 71px; height: 71px; }
.paid .money-row.busy { gap: 8px; }
.paid .money-row.busy .bill img { width: 126px; }
.paid .money-row.busy .coin.c1 img { width: 46px; height: 46px; }
.paid .money-row.busy .coin.c5 img { width: 51px; height: 51px; }
.paid .money-row.busy .coin.c10 img { width: 43px; height: 43px; }
.paid .money-row.busy .coin.c25 img { width: 58px; height: 58px; }
.due { grid-area: due; display: flex; align-items: center; gap: 10px; justify-self: end; }
.due-value { font-size: 1.6rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.due-value.hidden-amt { color: var(--muted); letter-spacing: .1em; }

/* ---------- money ---------- */
.money-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 56px; }
.money { position: relative; flex: none; user-select: none; -webkit-user-select: none; }
.money img { display: block; pointer-events: none; }
.bill img { width: 128px; height: auto; border-radius: 4px; box-shadow: 0 2px 4px rgba(60,40,20,.3); }
.coin img { border-radius: 50%; box-shadow: 0 2px 4px rgba(60,40,20,.35); object-fit: cover; }
/* coin sizes proportional to real diameters (penny 19.05mm, nickel 21.21, dime 17.91, quarter 24.26) */
.coin.c1 img { width: 48px; height: 48px; }
.coin.c5 img { width: 54px; height: 54px; }
.coin.c10 img { width: 45px; height: 45px; }
.coin.c25 img { width: 61px; height: 61px; }
.count {
  position: absolute; top: -8px; right: -8px; background: var(--berry); color: #fff; font-weight: 900; font-size: .85rem;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center;
  border: 2px solid #fff;
}
.small-money .bill img { width: 96px; }
.small-money .coin.c1 img { width: 36px; height: 36px; }
.small-money .coin.c5 img { width: 40px; height: 40px; }
.small-money .coin.c10 img { width: 34px; height: 34px; }
.small-money .coin.c25 img { width: 46px; height: 46px; }

/* ---------- tray ---------- */
.tray-head { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin-bottom: 8px; }
.tray-head h2 { margin: 0; }
.tray-total { font-weight: 900; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.tray-items { min-height: 84px; background: var(--surface-2); border: 2px dashed var(--line-strong); border-radius: 14px; padding: 12px; gap: 12px; }
.tray-items .money { cursor: pointer; }
.tray-items .money:hover img { filter: brightness(.92); }
.tray-items .empty { color: var(--muted); margin: 0; }
.added { animation: drop .2s ease-out; }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- result ---------- */
.result { margin-top: 10px; border-radius: 14px; padding: 12px 14px; border: 2px solid transparent; }
.result.correct { background: var(--good-bg); border-color: #b9e6c9; }
.result.suboptimal { background: var(--warn-bg); border-color: #f3d79f; }
.result.wrong { background: var(--bad-bg); border-color: #f5c0c0; }
.result h3 { margin: 0 0 4px; font-size: 1.3rem; font-weight: 900; }
.result.correct h3 { color: var(--good); }
.result.suboptimal h3 { color: var(--warn); }
.result.wrong h3 { color: var(--bad); }
.result p { margin: 4px 0; }
.result .bonus { display: inline-block; background: var(--gold); border-radius: 999px; padding: 1px 10px; margin-left: 4px; font-weight: 900; }
.result .compare { margin: 8px 0; }
.result .compare .money-row { min-height: 0; margin-top: 6px; }
.result .tips { margin: 6px 0; padding-left: 20px; }
.result .next-row { display: flex; justify-content: flex-end; margin-top: 6px; }

/* ---------- drawer: a sand-colored till, bills on top, coins below ---------- */
.drawer { background: var(--surface-3); border: 2px solid var(--line-strong); border-radius: var(--radius); padding: 10px; box-shadow: 0 4px 0 var(--line-strong); }
.till-row { display: grid; gap: 8px; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.till-row + .till-row { margin-top: 8px; }
/* Both mode on wide screens: bills and coins side by side in one row, like a real till */
.till.both { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); gap: 8px; }
.till.both .till-row + .till-row { margin-top: 0; }
.till.both .slot .bill img { width: min(120px, 100%); }
.till.both .slot .coin.c1 img { width: 50px; height: 50px; }
.till.both .slot .coin.c5 img { width: 56px; height: 56px; }
.till.both .slot .coin.c10 img { width: 47px; height: 47px; }
.till.both .slot .coin.c25 img { width: 64px; height: 64px; }
@media (max-width: 1000px) { .till.both { grid-template-columns: 1fr; } }
.slot {
  position: relative; background: var(--surface); border: 2px solid var(--line-strong); border-radius: 14px; padding: 12px 6px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 94px; padding-top: 10px;
  box-shadow: 0 4px 0 var(--line-strong); transition: transform .05s, box-shadow .05s, border-color .1s; color: var(--ink);
}
.slot:hover { border-color: var(--brand); }
.slot:active, .slot.flash { transform: translateY(4px); box-shadow: 0 0 0 transparent; border-color: var(--brand); }
.slot .name { font-weight: 800; font-size: .9rem; }
.slot kbd { position: absolute; top: 6px; left: 6px; margin: 0; font-size: .8rem; }
.slot .bill img { width: min(166px, 100%); }
.slot .money { max-width: 100%; }
.slot .coin.c1 img { width: 58px; height: 58px; }
.slot .coin.c5 img { width: 65px; height: 65px; }
.slot .coin.c10 img { width: 55px; height: 55px; }
.slot .coin.c25 img { width: 74px; height: 74px; }

/* ---------- stats view ---------- */
.stats-view { display: flex; flex-direction: column; gap: 12px; }
.stats-mode { margin: 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; box-shadow: var(--chunk); display: flex; flex-direction: column; }
.stat .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; }
.stat .v { font-size: 1.5rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.25); } }

.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 8px; }

/* ---------- shop ledger ---------- */
.ledger h3 { font-size: .95rem; font-weight: 800; color: var(--muted); margin: 14px 0 8px; }
.ledger h3 small { font-weight: 700; margin-left: 4px; }
.ledger-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.lg-tile { background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; display: flex; flex-direction: column; }
.lg-tile .k { font-size: .8rem; color: var(--muted); font-weight: 800; }
.lg-tile b { font-size: 1.45rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.lg-tile small { color: var(--muted); font-variant-numeric: tabular-nums; }
.lg-tile.hero { background: #e8f8f3; border-color: #a9e2d5; }
.lg-tile.hero b { color: var(--brand-dark); }
.denoms { display: flex; flex-wrap: wrap; gap: 10px; }
.denom { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--surface-2); border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; min-width: 84px; }
.denom b { font-variant-numeric: tabular-nums; font-weight: 900; }
.denom .bill img { width: 76px; }
.denom .coin.c1 img { width: 32px; height: 32px; }
.denom .coin.c5 img { width: 36px; height: 36px; }
.denom .coin.c10 img { width: 30px; height: 30px; }
.denom .coin.c25 img { width: 40px; height: 40px; }
.denom.zero { opacity: .45; }
.highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; margin-top: 12px; }
.hl { background: var(--surface-2); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; line-height: 1.35; }
.hl .k { display: block; font-size: .8rem; color: var(--muted); font-weight: 800; }
.hl b { font-weight: 900; }
.met { display: flex; flex-wrap: wrap; gap: 8px; }
.met-card { width: 74px; text-align: center; background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; padding: 6px 4px; }
.met-card .face { font-size: 2rem; line-height: 1.2; }
.met-card small { display: block; font-size: .7rem; color: var(--muted); line-height: 1.15; }
.met-card.unmet .face { filter: grayscale(1) brightness(1.6); opacity: .35; }
.met-card.rare { border-color: #c9b3f5; background: #f4edff; }
.ach { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; padding: 8px 10px; }
.ach .icon { font-size: 1.7rem; flex: none; }
.ach .t { font-weight: 900; font-size: .9rem; line-height: 1.15; }
.ach .d { font-size: .75rem; color: var(--muted); line-height: 1.2; margin-top: 2px; }
.ach.locked .icon { filter: grayscale(1); opacity: .35; }
.ach.locked .t { color: var(--muted); }
.ach.got { background: #fff7dc; border-color: var(--gold); }

.progress { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 860px) { .progress { grid-template-columns: 1fr; } }
.chart { min-height: 120px; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart .axis { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--font); font-weight: 700; }
.chart .axis.strong { fill: var(--ink); font-weight: 900; }
.chart .hit { cursor: pointer; }
.chart-empty { color: var(--muted); margin: 24px 0; text-align: center; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; background: var(--c); }
.sw.dot { border-radius: 50%; }
.sw.box { border-radius: 2px; }
.sw.diamond { transform: rotate(45deg) scale(.85); }
.sw.line { height: 2px; width: 16px; border-radius: 1px; }
.sw.cross { background: none; position: relative; }
.sw.cross::before, .sw.cross::after { content: ''; position: absolute; left: 4px; top: -1px; width: 2.5px; height: 12px; background: var(--c); border-radius: 1px; }
.sw.cross::before { transform: rotate(45deg); }
.sw.cross::after { transform: rotate(-45deg); }
.chart-tip {
  position: fixed; z-index: 20; pointer-events: none; display: none; background: var(--surface); color: var(--ink);
  border: 2px solid var(--line-strong); padding: 7px 10px; border-radius: 10px; font-size: .85rem; line-height: 1.35; box-shadow: 0 4px 0 var(--line-strong);
}
.chart-tip .muted { color: var(--muted); }

.history { overflow-x: auto; }
.history table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.history th, .history td { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--surface-2); white-space: nowrap; }
.history th { color: var(--muted); font-weight: 800; font-size: .85rem; }
.tag { padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 900; }
.tag.correct { background: var(--good-bg); color: var(--good); }
.tag.suboptimal { background: var(--warn-bg); color: var(--warn); }
.tag.wrong { background: var(--bad-bg); color: var(--bad); }

/* ---------- settings tab ---------- */
.settings-view { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; align-items: start; }
.settings { display: flex; flex-direction: column; gap: 8px; }
.settings h2 { margin: 0 0 2px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; cursor: pointer;
  background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px;
}
.opt:hover { border-color: var(--line-strong); }
.opt input[type=checkbox] { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--brand); flex: none; cursor: pointer; }
.opt span { display: flex; flex-direction: column; gap: 2px; }
.opt b { font-weight: 800; }
.opt small { color: var(--muted); font-weight: 600; line-height: 1.3; }
.opt.select { align-items: center; justify-content: space-between; cursor: default; }
.opt select { border: 2px solid var(--line-strong); border-radius: 10px; padding: 6px 10px; background: var(--surface); color: var(--ink); font-weight: 800; flex: none; }
.settings .note { margin: 0; color: var(--muted); line-height: 1.4; }
.settings .reset-row { display: flex; gap: 10px; flex-wrap: wrap; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 12px; color: var(--muted); }
.keys-grid span { line-height: 1.5; }
.keys-grid kbd { margin: 0 6px 0 0; font-size: .8rem; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(45,34,25,.35); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal-card {
  background: var(--surface); border: 3px solid var(--line-strong); border-radius: 24px; box-shadow: 0 8px 0 var(--line-strong);
  padding: 24px 28px; text-align: center; max-width: 420px; width: 100%; animation: enter .3s cubic-bezier(.2,.9,.3,1.3);
}
.modal-card .big { font-size: 4rem; line-height: 1; }
.modal-card h3 { font-size: 1.6rem; font-weight: 900; margin: 8px 0 4px; }
.modal-card p { margin: 6px 0; color: var(--muted); }
.modal-card .count-down { font-size: 6rem; font-weight: 900; color: var(--flame); line-height: 1; }
.modal-card .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.modal-card .grid div { background: var(--surface-2); border-radius: 12px; padding: 8px; }
.modal-card .grid b { display: block; font-size: 1.5rem; font-weight: 900; color: var(--ink); }
.modal-card .grid small { color: var(--muted); }
.modal-card .row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* ---------- toasts & confetti ---------- */
.toasts { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100% - 32px); }
.toast {
  background: var(--surface); color: var(--ink); font-weight: 900; border: 2px solid var(--line-strong);
  padding: 10px 18px; border-radius: 999px; box-shadow: 0 4px 0 var(--line-strong); font-size: 1.05rem; text-align: center;
  animation: toastIn .3s cubic-bezier(.2,.9,.3,1.3);
}
.toast.ach { background: #fff7dc; border-color: var(--gold-dark); box-shadow: 0 4px 0 var(--gold-dark); }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { transform: translateY(-30px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-30px); opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 35; }

/* ---------- small screens ---------- */
@media (max-width: 700px) {
  .lcd { font-size: 1.7rem; }
  .bill img { width: 100px; }
  .avatar { width: 64px; height: 64px; font-size: 2.5rem; border-radius: 18px; }
  .register { grid-template-columns: 1fr; grid-template-areas: "item" "lcd" "plabel" "money" "due"; }
  .lcd-row { justify-self: start; }
  .due { justify-self: stretch; }
  .due .btn { margin-left: auto; }
  .paid .bill img { width: 118px; }
  .paid .coin.c1 img { width: 46px; height: 46px; }
  .paid .coin.c5 img { width: 51px; height: 51px; }
  .paid .coin.c10 img { width: 43px; height: 43px; }
  .paid .coin.c25 img { width: 58px; height: 58px; }
  .paid .money-row.busy .bill img { width: 100px; }
  .till-row.bills { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .slot { min-height: 90px; }
  .slot .coin.c1 img { width: 42px; height: 42px; }
  .slot .coin.c5 img { width: 47px; height: 47px; }
  .slot .coin.c10 img { width: 40px; height: 40px; }
  .slot .coin.c25 img { width: 54px; height: 54px; }
  .slot .name { font-size: .75rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chip { min-width: 0; padding: 4px 9px; }
}

/* touch devices have no keyboard: hide hotkey hints */
@media (hover: none) and (pointer: coarse) {
  .btn kbd, .slot kbd { display: none; }
}

/* fast tapping: no double-tap zoom, no grey tap flash, no accidental text selection */
button, .slot, .tray-items .money { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.slot, .btn, .chip { -webkit-user-select: none; user-select: none; }

/* ============ PHONE (≤600px): compact screen, till docked to the bottom ============ */
@media (max-width: 600px) {
  body { padding: 8px 10px 12px; }
  .title-text, .lbl, .profile .pill, #hudbar .chip:nth-child(3), .xp-top span, .lcd-label, .btn kbd, .slot kbd { display: none; }
  .topbar { gap: 8px; margin-bottom: 8px; flex-wrap: nowrap; }
  .seg button { padding: 6px 10px; }
  .modes button { padding: 5px 9px; font-size: 1.05rem; }

  .profile { padding: 6px 8px; gap: 8px; flex-wrap: nowrap; margin-bottom: 8px; }
  .level-badge { width: 32px; height: 32px; font-size: 1rem; border-radius: 9px; box-shadow: 0 2px 0 #5a3fb0; }
  .xp { min-width: 0; flex: 1 1 auto; }
  .xp-top { font-size: .75rem; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bar { height: 9px; }
  .hudbar { gap: 6px; flex-wrap: nowrap; margin-left: 0; }
  .chip { min-width: 0; padding: 3px 8px; box-shadow: 0 2px 0 var(--line); }
  .chip b { font-size: .95rem; }
  .btn.rush-btn { padding: 5px 10px; }

  .play { gap: 8px; }
  .card { padding: 10px; border-radius: 14px; }
  .counter { grid-template-columns: 1fr; gap: 8px; }
  .customer { gap: 10px; }
  .avatar { width: 46px; height: 46px; font-size: 1.8rem; border-radius: 13px; box-shadow: 0 3px 0 var(--line-strong); }
  .cname { font-size: .9rem; }
  .bubble { margin-top: 3px; padding: 5px 9px; font-size: .9rem; }
  .bubble::before { top: 8px; }
  .bubble::after { top: 9px; }
  .patience { margin-top: 5px; }

  .register { padding: 8px 10px; gap: 4px 8px; grid-template-columns: 1fr auto; grid-template-areas: "item lcd" "plabel plabel" "money money" "due due"; }
  .receipt-line { font-size: .95rem; }
  .lcd-row { justify-self: end; }
  .lcd { font-size: 1.5rem; padding: 0 8px; }
  .label strong { font-size: 1.05rem; }
  .due { justify-self: stretch; }
  .due-value { font-size: 1.3rem; }
  .due .btn { margin-left: auto; }
  .paid .bill img { width: 96px; }
  .paid .coin.c1 img { width: 40px; height: 40px; }
  .paid .coin.c5 img { width: 44px; height: 44px; }
  .paid .coin.c10 img { width: 38px; height: 38px; }
  .paid .coin.c25 img { width: 50px; height: 50px; }
  .paid .money-row.busy .bill img { width: 78px; }
  .paid .money-row.busy .coin.c1 img { width: 34px; height: 34px; }
  .paid .money-row.busy .coin.c5 img { width: 38px; height: 38px; }
  .paid .money-row.busy .coin.c10 img { width: 32px; height: 32px; }
  .paid .money-row.busy .coin.c25 img { width: 42px; height: 42px; }

  .tray-head { margin-bottom: 6px; }
  .tray-head h2 { font-size: .9rem; }
  .tray-items { min-height: 64px; padding: 8px; gap: 8px; }
  .tray-items .bill img { width: 84px; }
  .tray-items .coin.c1 img { width: 36px; height: 36px; }
  .tray-items .coin.c5 img { width: 40px; height: 40px; }
  .tray-items .coin.c10 img { width: 34px; height: 34px; }
  .tray-items .coin.c25 img { width: 46px; height: 46px; }
  .result { padding: 10px; }
  .result h3 { font-size: 1.1rem; }

  /* the docked till */
  .dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--surface-3); border-top: 2px solid var(--line-strong); box-shadow: 0 -6px 16px rgba(60,40,20,.12);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
  .dock .actions { margin: 0 0 8px; flex-wrap: nowrap; }
  .dock .actions .btn { padding: 9px 12px; }
  .dock .actions .primary { flex: 1; font-size: 1.05rem; }
  .dock .drawer { background: none; border: 0; box-shadow: none; padding: 0; border-radius: 0; }
  .dock .till.both { grid-template-columns: 1fr; gap: 6px; }
  .dock .till-row.bills, .dock .till-row.coins { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; }
  .dock .till-row + .till-row { margin-top: 6px; }
  .dock .till.both .till-row + .till-row { margin-top: 0; }
  .dock .slot { min-height: 0; padding: 6px 2px 4px; gap: 2px; border-radius: 10px; box-shadow: 0 3px 0 var(--line-strong); }
  .dock .slot .bill img, .dock .till.both .slot .bill img { width: 100%; max-width: 96px; }
  .dock .slot .coin.c1 img, .dock .till.both .slot .coin.c1 img { width: 34px; height: 34px; }
  .dock .slot .coin.c5 img, .dock .till.both .slot .coin.c5 img { width: 38px; height: 38px; }
  .dock .slot .coin.c10 img, .dock .till.both .slot .coin.c10 img { width: 32px; height: 32px; }
  .dock .slot .coin.c25 img, .dock .till.both .slot .coin.c25 img { width: 42px; height: 42px; }
  /* coins-only mode: just 4 slots, so make them bigger */
  .dock .till:not(.both) .slot .coin.c1 img { width: 44px; height: 44px; }
  .dock .till:not(.both) .slot .coin.c5 img { width: 49px; height: 49px; }
  .dock .till:not(.both) .slot .coin.c10 img { width: 41px; height: 41px; }
  .dock .till:not(.both) .slot .coin.c25 img { width: 56px; height: 56px; }
  .slot .name { font-size: .8rem; }
  .slot .long { display: none; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-card { padding: 18px; }
}

/* ============ TABLET PORTRAIT (iPad upright): bigger touch targets, use the height ============ */
@media (min-width: 601px) and (max-width: 1100px) and (orientation: portrait) {
  body { max-width: none; padding: 14px 18px 24px; }
  .play { gap: 14px; }
  .avatar { width: 96px; height: 96px; font-size: 3.8rem; }
  .bubble { font-size: 1.1rem; }
  .lcd { font-size: 2.6rem; }
  .tray-items { min-height: 120px; }
  .tray-items .bill img { width: 140px; }
  .slot { min-height: 128px; }
  .slot .bill img, .till.both .slot .bill img { width: min(170px, 100%); }
  .slot .coin.c1 img, .till.both .slot .coin.c1 img { width: 66px; height: 66px; }
  .slot .coin.c5 img, .till.both .slot .coin.c5 img { width: 73px; height: 73px; }
  .slot .coin.c10 img, .till.both .slot .coin.c10 img { width: 62px; height: 62px; }
  .slot .coin.c25 img, .till.both .slot .coin.c25 img { width: 84px; height: 84px; }
  .slot .name { font-size: 1rem; }
  .btn.primary { font-size: 1.2rem; padding: 13px 26px; }
}

/* settings: one column on phones */
@media (max-width: 600px) {
  .settings-view { grid-template-columns: 1fr; }
  .settings-view .settings:has(.keys-grid) { display: none; } /* no keyboard on phones */
}
