/* Coin Shop: a cosy toy shop at closing time. The page is a deep plum like
   the shop's back room, so the lamp-lit counter glows; the price sits on a
   cream receipt and the coins sit in a dark wood tray. Figtree (clear,
   open numerals) for words and numbers, Gluten for the shop's name. */

:root {
  --plum: #2a1a2c;
  --plum-deep: #1d1220;
  --plum-light: #3d2840;
  --wood: #5c321a;
  --wood-dark: #3f2111;
  --brass: #e6b85c;
  --brass-hi: #ffe6a0;
  --brass-deep: #9a6a1f;
  --paper: #fff6e4;
  --ink: #2a1824;
  --ink-soft: #6a4c5e;
  --rose: #b5302a;
  --mint: #2f7a5c;
  --text: #f8eef3;
  --text-soft: #cfbac7;

  --display: "Gluten", "Arial Rounded MT Bold", cursive;
  --body: "Figtree", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--plum);
  color: var(--text);
  font: 500 1.0625rem/1.5 var(--body);
}

.shop {
  max-width: 66rem;
  margin: 0 auto;
  padding: clamp(0.6rem, 2vw, 1.4rem) clamp(1rem, 3vw, 2rem) 2.5rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
  margin-bottom: 0.8rem;
}
.back { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--text-soft); font-weight: 700; text-underline-offset: 3px; }
.back:hover { color: var(--text); }
h1 {
  margin: 0;
  flex: 1;
  font: 700 clamp(1.6rem, 3.6vw, 2.4rem)/1 var(--display);
  color: var(--brass);
}

.levels { display: flex; gap: 0.3rem; padding: 0.3rem; border-radius: 1.4rem; background: var(--plum-deep); }
.levels button {
  min-height: 2.75rem;
  font: 700 0.95rem/1.15 var(--body);
  padding: 0.4rem 0.9rem;
  border: 0;
  border-radius: 1.1rem;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}
.levels button[aria-pressed="true"] { background: var(--brass); color: #2e1f04; }
.levels button:hover:not([aria-pressed="true"]) { color: var(--text); }

.stage {
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.45);
}

/* the receipt: what the toy costs, what's on the counter, and what to do */
.ticket {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "ask total" "addup total" "hint hint";
  align-items: center;
  gap: 0.1rem 1.25rem;
  padding: 0.7rem 1.3rem 0.75rem;
  background: var(--paper);
  color: var(--ink);
  border-top: 0.4rem solid var(--brass);
}
.ask {
  grid-area: ask;
  margin: 0;
  font: 800 clamp(1.5rem, 3.6vw, 2.1rem)/1.15 var(--body);
}
.addup {
  grid-area: addup;
  margin: 0;
  font: 700 1.15rem/1.3 var(--body);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.total {
  grid-area: total;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 0;
  text-align: right;
}
.total-label { font-size: 0.95rem; font-weight: 700; color: var(--ink-soft); }
.total strong {
  font: 800 clamp(2.2rem, 5vw, 3rem)/1 var(--body);
  font-variant-numeric: tabular-nums;
  color: var(--mint);
}
.hint {
  grid-area: hint;
  margin: 0.35rem 0 0;
  min-height: 3em;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.stage canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100svh - 21rem);
  touch-action: none;
  background: #d9776e;
}
.stage canvas:focus-visible { outline: 4px solid var(--brass-hi); outline-offset: -4px; }

/* the tray under the counter: real buttons, sized like the coins */
.till {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.6rem 1rem 0.7rem;
  background: linear-gradient(var(--wood), var(--wood-dark));
}
.coins { display: flex; align-items: flex-end; gap: 0.35rem; }
.coin {
  --d: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 3.6rem;
  min-height: 2.75rem;
  padding: 0.2rem 0.25rem;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: var(--text);
  font: 700 0.95rem/1 var(--body);
  cursor: pointer;
}
.coin[hidden] { display: none; }
.coin .face {
  display: grid;
  place-items: center;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffffff, #c6ccd6 55%, #7f8794);
  box-shadow: inset 0 0 0 0.18rem rgba(60, 70, 85, 0.35), 0 0.2rem 0 #4a505b;
  color: #252b36;
  font: 800 1rem/1 var(--body);
  font-variant-numeric: tabular-nums;
}
.coin.copper .face {
  --d: 2.85rem;
  background: radial-gradient(circle at 32% 28%, #ffd2a8, #d17a43 55%, #8c4320);
  box-shadow: inset 0 0 0 0.18rem rgba(110, 45, 15, 0.35), 0 0.2rem 0 #5a2810;
  color: #3a1606;
}
.coin.small .face { --d: 2.65rem; }
.coin.big .face { --d: 3.4rem; font-size: 1.05rem; }
.coin.bill { order: -1; }
.coin.bill .face {
  width: 4.2rem;
  height: 2.3rem;
  border-radius: 0.3rem;
  background: linear-gradient(135deg, #e3efd6, #bcd4ab);
  box-shadow: inset 0 0 0 0.16rem #3d6b45, 0 0.2rem 0 #24402b;
  color: #1f4027;
}
.coin .name { color: var(--text-soft); }
.coin:hover .face { filter: brightness(1.08); }
.coin:active .face { transform: translateY(0.12rem); box-shadow: none; }

.actions { display: flex; gap: 0.5rem; }
.take,
.pay {
  min-height: 2.9rem;
  padding: 0.6rem 1.15rem;
  border-radius: 999px;
  font: 800 1.05rem/1 var(--body);
  cursor: pointer;
}
.take { border: 2px solid rgba(255, 230, 160, 0.45); background: transparent; color: var(--brass-hi); }
.take:hover { border-color: var(--brass-hi); }
.pay {
  min-width: 7.5rem;
  border: 0;
  background: linear-gradient(var(--brass-hi), var(--brass) 45%, #c08a2e);
  box-shadow: 0 0.2rem 0 var(--brass-deep);
  color: #2e1f04;
}
.pay:hover { filter: brightness(1.06); }
.pay:active { transform: translateY(0.12rem); box-shadow: none; }

.below {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 0.9rem;
}
.progress {
  display: grid;
  grid-template-columns: repeat(8, 2.6rem);
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.progress li {
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  background: var(--plum-deep);
  color: var(--brass);
  font-size: 0.65rem;
  letter-spacing: -0.05em;
}
.progress li.now { box-shadow: inset 0 0 0 2px var(--brass); }
.progress li.done { background: var(--plum-light); }

.tally { display: flex; gap: 1.25rem; margin: 0 0 0 auto; }
.tally div { display: flex; align-items: baseline; gap: 0.4rem; }
.tally dt { font-size: 0.95rem; color: var(--text-soft); }
.tally dd { margin: 0; font-weight: 800; font-size: 1.35rem; font-variant-numeric: tabular-nums; }

.again {
  min-height: 2.75rem;
  font: 700 1rem/1 var(--body);
  padding: 0.7rem 1.2rem;
  border: 2px solid var(--brass);
  border-radius: 999px;
  background: transparent;
  color: var(--brass-hi);
  cursor: pointer;
}
.again:hover { background: var(--plum-light); }

/* the shelf at home */
.bought { margin-top: 1.6rem; }
.bought h2 { margin: 0 0 0.5rem; font: 700 1.35rem/1.2 var(--display); color: var(--brass); }
.bought .empty { margin: 0; color: var(--text-soft); }
.bought ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.bought ul:empty { display: none; }
.bought li {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 7rem;
  padding: 0.4rem 0.3rem 0.5rem;
  border-bottom: 0.35rem solid #8f5528;
  border-radius: 0.6rem 0.6rem 0.2rem 0.2rem;
  background: var(--plum-light);
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}
.bought li canvas { display: block; width: 4rem; height: 4rem; }

.keys,
.about { max-width: 46rem; margin: 1.4rem 0 0; font-size: 0.95rem; color: var(--text-soft); }
.about { margin-top: 0.7rem; }

.again:focus-visible,
.levels button:focus-visible,
.coin:focus-visible,
.take:focus-visible,
.pay:focus-visible,
.back:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* one column under about 900 px: the levels wrap under the title */
@media (max-width: 900px) {
  .levels { width: 100%; }
  .levels button { flex: 1; }
  .stage canvas { aspect-ratio: 4 / 3; max-height: calc(100svh - 24rem); }
}

@media (max-width: 760px) {
  .shop { padding-top: 0.5rem; }
  .top { gap: 0 1rem; margin-bottom: 0.55rem; }
  .levels { display: grid; grid-template-columns: 1fr 1fr; border-radius: 1rem; }
  .levels button { padding: 0.3rem 0.5rem; font-size: 1rem; border-radius: 0.75rem; }
  .ticket { padding: 0.5rem 0.8rem 0.55rem; gap: 0 0.75rem; border-top-width: 0.3rem; }
  .ask { font-size: 1.3rem; }
  .addup { font-size: 1.05rem; }
  .total strong { font-size: 2rem; }
  .hint { font-size: 1rem; min-height: 4.4em; line-height: 1.45; margin-top: 0.2rem; }
  .stage canvas { aspect-ratio: auto; height: clamp(14rem, 100svh - 33rem, 26rem); max-height: none; }
  .till { padding: 0.5rem 0.6rem 0.6rem; }
  .coins { width: 100%; justify-content: space-between; }
  .coin { min-width: 0; flex: 1; font-size: 1rem; }
  .actions { width: 100%; }
  .take, .pay { flex: 1; }
  .below { margin-top: 0.7rem; gap: 0.6rem 1rem; }
  .progress { grid-template-columns: repeat(8, 1fr); width: 100%; }
  .progress li { height: 1.9rem; }
  .tally { margin: 0; }
  .again { margin-left: auto; }
  .keys, .about, .total-label, .tally dt, .bought li { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .coin:active .face, .pay:active { transform: none; }
}
