/* Heart Claw: a candy-shop claw machine. A strawberry-milk page in plum ink,
   Shrikhand for the ice-cream-parlour names and Lexend (made for easy reading)
   for words. The machine itself carries the colour. */

:root {
  --milk: #fbe1ea;
  --milk-deep: #f5cddc;
  --plum: #3b1838;
  --plum-soft: #74466c;
  --bubblegum: #ff8fb8;
  --cherry: #d93a70;
  --cherry-deep: #a8285a;
  --mint: #a8e6cf;
  --lilac: #c9b6f2;
  --butter: #ffe28a;
  --chrome: #e4e7ef;

  --display: "Shrikhand", "Arial Rounded MT Bold", serif;
  --body: "Lexend", system-ui, sans-serif;
}

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

html { color-scheme: light; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--milk);
  color: var(--plum);
  font: 400 1rem/1.55 var(--body);
}

/* desktop: the machine on the left, everything else in a column beside it */
.shop {
  max-width: 76rem;
  margin: 0 auto;
  padding: clamp(0.75rem, 2.5vw, 1.75rem) clamp(1rem, 3vw, 2rem) 2.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 22rem);
  grid-template-areas:
    "machine top"
    "machine tally"
    "machine side";
  grid-template-rows: auto auto 1fr;
  gap: 0 clamp(1.5rem, 3.5vw, 3rem);
  align-items: start;
}

.top { grid-area: top; }
.tally { grid-area: tally; }
.machine { grid-area: machine; }
.side { grid-area: side; }

.back { display: inline-block; color: var(--plum-soft); font-weight: 600; text-underline-offset: 3px; }
.back:hover { color: var(--plum); }

h1 {
  margin: 0.2rem 0 1rem;
  font: 400 clamp(2.2rem, 4.5vw, 3.3rem)/1 var(--display);
  color: var(--cherry);
  text-shadow: 0.06em 0.06em 0 #fff;
}

.tally {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 0 0 2px var(--milk-deep);
}
.tally div { display: grid; gap: 0.1rem; }
.tally dt { font-size: 0.85rem; color: var(--plum-soft); }
.tally dd { margin: 0; font: 400 1.6rem/1 var(--display); font-variant-numeric: tabular-nums; }
.tally .tries { flex: 1; }
.tally .tries dd { display: flex; align-items: center; gap: 0.6rem; color: var(--cherry-deep); }

.coins {
  display: grid;
  grid-template-columns: repeat(10, 0.8rem);
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.coins li {
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8dc, var(--butter) 55%, #d9a93a);
  box-shadow: inset 0 0 0 1px rgba(150, 100, 20, 0.35);
}
.coins li.spent { background: var(--milk); box-shadow: inset 0 0 0 1.5px var(--milk-deep); }

.machine { position: sticky; top: 1rem; }

canvas {
  display: block;
  width: min(100%, calc(100svh - 11.5rem));
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 1.25rem;
  background: var(--milk-deep);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
canvas:active { cursor: grabbing; }
canvas:focus-visible { outline: 4px solid var(--plum); outline-offset: 4px; }

/* the control deck: a d-pad on the left, a big arcade button on the right */
.pad {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 6vw, 3.5rem);
  margin-top: 0.85rem;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 3.25rem);
  grid-template-rows: repeat(2, 3.25rem);
  grid-template-areas: ". up ." "left down right";
  gap: 0.3rem;
}
.back-dir { grid-area: up; }
.left-dir { grid-area: left; }
.front-dir { grid-area: down; }
.right-dir { grid-area: right; }

.dir {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0.9rem;
  background: var(--lilac);
  color: var(--plum);
  box-shadow: inset 0 -4px 0 rgba(59, 24, 56, 0.22);
  cursor: pointer;
  touch-action: none;
}
.dir svg { width: 1.3rem; height: 1.3rem; fill: currentColor; }
.dir:hover { background: #d7c8f7; }
.dir.held,
.dir:active { box-shadow: inset 0 2px 0 rgba(59, 24, 56, 0.22); transform: translateY(2px); }

.drop {
  width: 6.25rem;
  height: 6.25rem;
  border: 0;
  border-radius: 50%;
  position: relative;
  background: radial-gradient(circle at 38% 30%, #c4336a, #b02c5f 55%, #8f1f4a);
  color: #fff;
  font: 400 1.5rem/1 var(--display);
  text-shadow: 0 2px 0 var(--cherry-deep);
  box-shadow: 0 6px 0 var(--cherry-deep), 0 0 0 5px var(--chrome), 0 6px 0 5px #b9bfcf;
  cursor: pointer;
  touch-action: manipulation;
}
.drop::before {
  content: "";
  position: absolute;
  left: 22%;
  top: 12%;
  width: 34%;
  height: 20%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.drop:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--cherry-deep), 0 0 0 5px var(--chrome), 0 2px 0 5px #b9bfcf; }
.drop[aria-disabled="true"] { filter: saturate(0.45); cursor: default; }
.drop[aria-disabled="true"]:active { transform: none; }

.hint { min-height: 3.1em; margin: 0 0 1rem; font-size: 1.05rem; font-weight: 600; }

.again {
  font: 600 1rem/1 var(--body);
  min-height: 2.9rem;
  padding: 0.75rem 1.3rem;
  border: 0;
  border-radius: 999px;
  background: var(--plum);
  color: #fff;
  cursor: pointer;
}
.again:hover { background: #55244f; }

.dir:focus-visible,
.drop:focus-visible,
.again:focus-visible,
.back:focus-visible { outline: 3px solid var(--plum); outline-offset: 3px; }
.drop:focus-visible { outline-offset: 8px; }

.prizes { margin-top: 1.75rem; }
h2 { margin: 0 0 0.6rem; font: 400 1.35rem/1.1 var(--display); color: var(--plum); }

/* the prize shelf: a wooden-pink ledge the plush sit on */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr));
  gap: 0.5rem 0.4rem;
  margin: 0;
  padding: 0 0 0.5rem;
  list-style: none;
  border-bottom: 0.45rem solid var(--bubblegum);
}
.shelf:empty { display: none; }
.shelf li { display: grid; justify-items: center; gap: 0.15rem; text-align: center; font-size: 0.75rem; line-height: 1.2; }
.shelf canvas {
  width: 3.5rem;
  height: 3.5rem;
  aspect-ratio: auto;
  border-radius: 0;
  background: none;
  cursor: default;
}
.empty { margin: 0; color: var(--plum-soft); }

.keys { margin: 1.75rem 0 0; font-size: 0.9rem; color: var(--plum-soft); }

@media (max-width: 760px) {
  .shop {
    grid-template-columns: 1fr;
    grid-template-areas: "top" "tally" "machine" "side";
    grid-template-rows: auto;
    padding: 0.6rem 1rem 2rem;
  }
  .top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
  .top .back { order: 2; font-size: 0.9rem; }
  h1 { margin: 0 0 0.4rem; font-size: 2rem; }
  .tally { gap: 1rem; margin-bottom: 0.6rem; padding: 0.5rem 0.8rem; }
  .tally dd { font-size: 1.35rem; }
  .coins { grid-template-columns: repeat(10, 0.55rem); gap: 0.15rem; }
  .machine { position: static; }
  canvas { width: 100%; }
  .pad { margin-top: 0.6rem; }
  .dpad { grid-template-columns: repeat(3, 3rem); grid-template-rows: repeat(2, 3rem); }
  .drop { width: 5.5rem; height: 5.5rem; font-size: 1.35rem; }
  .side { margin-top: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .dir.held,
  .dir:active,
  .drop:active { transform: none; }
}

/* help text stays at reading size on phones */
@media (max-width: 760px) {
  #keys { font-size: 1rem; }
}
