* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: ui-rounded, "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: #2a2140;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 90, 140, 0.18) 0 60px, transparent 61px),
    radial-gradient(circle at 88% 30%, rgba(60, 170, 255, 0.18) 0 80px, transparent 81px),
    radial-gradient(circle at 20% 85%, rgba(255, 210, 40, 0.2) 0 70px, transparent 71px),
    radial-gradient(circle at 85% 88%, rgba(60, 200, 110, 0.18) 0 50px, transparent 51px),
    #fff7ec;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.hidden { display: none !important; }

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  gap: 8px;
  touch-action: none;
}

/* ---------- buttons ---------- */

.pill {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  background: #fff;
  border: 2px solid #2a2140;
  border-radius: 999px;
  padding: 0 16px;
  min-height: 44px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 3px 0 #2a2140;
}
.pill:active { transform: translateY(2px); box-shadow: 0 1px 0 #2a2140; }
.pill.on { background: #ffe14d; }

.big {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1.5px;
  border: 2px solid #2a2140;
  border-radius: 999px;
  padding: 0 24px;
  min-height: 50px;
  color: #fff;
  background: #ff4f8b;
  box-shadow: 0 4px 0 #2a2140;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 #2a2140; }

.round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #2a2140;
  background: #fff;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 3px 0 #2a2140;
  padding: 0;
}
.round:active { transform: translateY(2px); box-shadow: 0 1px 0 #2a2140; }

/* ---------- top ---------- */

#top {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  /* the arcade's back link sits top left */
  padding-left: 150px;
}

/* ---------- the machine ---------- */

#stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#machine {
  position: relative;
  width: 300px;
  height: 300px;
  touch-action: none;
  cursor: crosshair;
}

#tub {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side, #59607a 0 80%, #3a3f55 85%, #c9cede 86.5%, #eef0f6 91%, #9aa1b8 96%, #5b6178 99%, #2a2140 100%);
  box-shadow: 0 10px 0 rgba(42, 33, 64, 0.25), 0 18px 30px rgba(42, 33, 64, 0.25);
}

#disc {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  will-change: transform;
}

#platter {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle, #d9dce6 0 5%, #8b91a8 5.5% 7%, transparent 7.5%),
    repeating-conic-gradient(#bfc4d4 0 10deg, #a9afc2 10deg 20deg);
  box-shadow: inset 0 0 0 4px #7b8199;
}

#paper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#clips {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#clips.square { transform: rotate(45deg); }
#clips i {
  position: absolute;
  left: 50%;
  top: 0.6%;
  width: 7%;
  height: 4%;
  margin-left: -3.5%;
  border-radius: 3px 3px 6px 6px;
  background: linear-gradient(#ff4f8b, #c2245c);
  border: 2px solid #2a2140;
  transform-origin: 50% 1235%;
}
#clips i:nth-child(2) { transform: rotate(90deg); }
#clips i:nth-child(3) { transform: rotate(180deg); }
#clips i:nth-child(4) { transform: rotate(270deg); }

#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- tools ---------- */

#tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 760px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 2px solid #2a2140;
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 3px 0 #2a2140;
}

#paints { gap: 4px; }

.bottle {
  position: relative;
  width: 38px;
  height: 56px;
  border: none;
  background: none;
  padding: 0;
  transition: transform 0.12s;
}
.bottle .body {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 0;
  height: 40px;
  border-radius: 9px 9px 7px 7px;
  border: 2px solid #2a2140;
  background: var(--ink);
  box-shadow: inset -5px 0 0 rgba(0, 0, 0, 0.15), inset 5px 0 0 rgba(255, 255, 255, 0.25);
}
.bottle .cap {
  position: absolute;
  left: 50%;
  bottom: 38px;
  width: 16px;
  height: 10px;
  margin-left: -8px;
  border-radius: 3px 3px 0 0;
  border: 2px solid #2a2140;
  background: #fff;
}
.bottle .cap::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 6px;
  height: 8px;
  margin-left: -3px;
  border-radius: 3px 3px 0 0;
  border: 2px solid #2a2140;
  background: #fff;
}
.bottle.rainbow .body {
  background: linear-gradient(#ff3b3b, #ff9b1f, #ffd51f, #2cc84d, #1f6bff, #8c4dff);
}
.bottle.on { transform: translateY(-8px) scale(1.08); }
.bottle.on .body { box-shadow: inset -5px 0 0 rgba(0, 0, 0, 0.15), inset 5px 0 0 rgba(255, 255, 255, 0.25), 0 0 0 3px #fff, 0 0 0 5px #2a2140; }

.speed {
  border: none;
  background: none;
  border-radius: 999px;
  min-height: 38px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
}
.speed.on { background: #2a2140; color: #ffe14d; }

.drop {
  width: 40px;
  height: 38px;
  border: none;
  background: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.drop span {
  display: block;
  border-radius: 50%;
  background: #2a2140;
}
.drop.on { background: #ffe14d; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(42, 33, 64, 0.45);
}

.card {
  background: #fff7ec;
  border: 3px solid #2a2140;
  border-radius: 24px;
  box-shadow: 0 8px 0 #2a2140;
  padding: 22px 24px;
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
}
.card.wide { width: min(760px, 100%); }
.card.small { width: min(340px, 100%); }

h1 {
  margin: 0;
  font-size: clamp(34px, 9vw, 54px);
  font-weight: 900;
  letter-spacing: 2px;
  -webkit-text-stroke: 2px #2a2140;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 #2a2140;
}
h1 span:nth-child(9n+1) { color: #ff3b5c; }
h1 span:nth-child(9n+2) { color: #ff8a1f; }
h1 span:nth-child(9n+3) { color: #ffd51f; }
h1 span:nth-child(9n+4) { color: #2cc84d; }
h1 span:nth-child(9n+5) { color: #14c4b8; }
h1 span:nth-child(9n+6) { color: #1f6bff; }
h1 span:nth-child(9n+7) { color: #8c4dff; }
h1 span:nth-child(9n+8) { color: #ff4fb0; }
h1 span:nth-child(9n+9) { color: #ff3b5c; }

h2 { margin: 0 0 12px; font-size: 24px; font-weight: 900; letter-spacing: 1.5px; }

.tag { margin: 8px 0 14px; font-weight: 700; }

.how {
  text-align: left;
  margin: 0 0 18px;
  padding-left: 22px;
  line-height: 1.45;
}
.how li { margin-bottom: 6px; }

.btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.note {
  margin: 0 0 12px;
  font-weight: 800;
  color: #c2245c;
}

.pickRow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.shapeBtn, .colorBtn {
  border: 3px solid #2a2140;
  background: #fff;
  padding: 0;
  box-shadow: 0 3px 0 #2a2140;
}
.shapeBtn {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shapeBtn span {
  display: block;
  width: 40px;
  height: 40px;
  border: 3px solid #2a2140;
  background: #fff;
}
.shapeBtn.circle span { border-radius: 50%; }
.shapeBtn.square span { border-radius: 4px; width: 36px; height: 36px; }
.shapeBtn.on { background: #ffe14d; }

.colorBtn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
}
.colorBtn.on { box-shadow: 0 0 0 4px #ffe14d, 0 0 0 6px #2a2140; }

/* ---------- gallery ---------- */

.galleryHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.galleryHead h2 { margin: 0; }

#galleryEmpty { margin: 20px 0; }

#galleryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.tile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 3px solid #2a2140;
  background: #fff;
  cursor: pointer;
}
.tile img.circle { border-radius: 50%; }
.tile img.square { border-radius: 8px; }
.tile .tbtns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.tile .pill { min-height: 34px; padding: 0 10px; font-size: 11px; }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  top: 70px;
  transform: translateX(-50%);
  z-index: 60;
  background: #2a2140;
  color: #fff;
  font-weight: 800;
  padding: 12px 20px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 520px) {
  .bottle { width: 32px; height: 50px; }
  .bottle .body { height: 34px; }
  .bottle .cap { bottom: 32px; }
  .speed { padding: 0 7px; font-size: 11px; }
}

/* ---------- coins, selling, the shop and the market ---------- */

.pill.coins { background: #ffe14d; cursor: default; }
.pill:disabled { opacity: 0.55; cursor: default; }
.pill.buy { background: #ffe14d; }
.pill.small { min-height: 36px; padding: 0 10px; font-size: 12px; box-shadow: 0 2px 0 #2a2140; }
#sellBtn { background: #7d3cff; }

#sellForm { display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: left; }
#sellPreview { width: 150px; height: 150px; align-self: center; object-fit: contain; }
#sell label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 800; letter-spacing: 0.5px; }
#sell input {
  font: inherit;
  font-size: 18px;
  color: #2a2140;
  background: #fff;
  border: 2px solid #2a2140;
  border-radius: 12px;
  padding: 10px 12px;
  user-select: text;
  -webkit-user-select: text;
}
.askRow { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; }
.askRow > span:first-child { flex: 1; }
.askBox { display: flex; align-items: center; gap: 4px; font-size: 18px; }
#sellAsk { width: 84px; text-align: center; }
.hint { margin: 0; font-size: 13px; opacity: 0.75; line-height: 1.4; }
.error { margin: 0; color: #c2245c; font-weight: 800; min-height: 1em; }

#sellResult { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.robotSays { display: flex; gap: 12px; align-items: flex-start; text-align: left; }
.robot { font-size: 46px; line-height: 1; }
.robot.thinking { animation: bob 0.6s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-6px) rotate(8deg); } }
.bubble {
  background: #fff;
  border: 2px solid #2a2140;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 700;
  line-height: 1.35;
}
.soldLine { font-size: 18px; margin-bottom: 4px; }

.offline { line-height: 1.5; }
.loading { opacity: 0.6; }

#shopList { display: flex; flex-direction: column; gap: 10px; }
.shopRow {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 2px solid #2a2140;
  border-radius: 16px;
  padding: 10px 12px;
  text-align: left;
}
.shopLook { width: 96px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; align-items: center; }
.shopLook .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #2a2140; }
.shopLook .dot.neon { box-shadow: 0 0 8px 2px var(--glow); }
.shopLook .dot.glitter { background-image: radial-gradient(circle at 30% 30%, #fff 0 2px, transparent 3px), radial-gradient(circle at 70% 65%, #fff 0 1.5px, transparent 2.5px) !important; }
.shopLook .bigDot { width: 46px; height: 46px; border-radius: 50%; background: #2a2140; }
.shopLook .word { font-size: 18px; font-weight: 900; }
.shopLook .icon { font-size: 34px; }
.shopWords { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.shopWords span { font-size: 13px; opacity: 0.75; }

.best {
  background: #fff3b0;
  border: 2px solid #2a2140;
  border-radius: 20px;
  padding: 14px;
  margin-bottom: 16px;
  text-align: center;
}
.bestTag { font-weight: 900; letter-spacing: 2px; margin-bottom: 4px; }
.bestPrize { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.marketGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.card-item { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; }
.card-item img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.card-item.featured img { width: min(260px, 70vw); }
.itemTitle { font-weight: 900; }
.itemBy { font-size: 12px; opacity: 0.7; }
.itemSays { font-size: 14px; max-width: 420px; }
.itemRow { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.report { background: none; border: none; font-size: 11px; opacity: 0.45; padding: 4px; box-shadow: none; }
.picLabel { font-size: 12px; text-align: center; font-weight: 700; }
.galleryHead h2 { flex: 1; text-align: left; }

/* paper pieces of shapes you can't see the corners of */
.tile img.heart, .tile img.star { border: none; background: none; border-radius: 0; }
.shapeBtn.heart span, .shapeBtn.star span { border: none; width: 44px; height: 44px; }
.shapeBtn.heart span { clip-path: path("M22 40 C8 30 0 22 2 13 C4 4 16 2 22 11 C28 2 40 4 42 13 C44 22 36 30 22 40 Z"); }
.shapeBtn.star span { clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.shapeBtn.locked { opacity: 0.4; }

@media (max-width: 600px) {
  #top { padding-left: 120px; flex-wrap: wrap; gap: 6px; }
  #top .pill { padding: 0 9px; font-size: 11px; min-height: 38px; }
}

#clips.none { display: none; }
.bottle.neon .body { box-shadow: inset -5px 0 0 rgba(0, 0, 0, 0.15), 0 0 10px 2px var(--ink); }
.bottle.glitter .body {
  background-image:
    radial-gradient(circle at 30% 30%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 70% 55%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 40% 80%, #fff 0 1.5px, transparent 2.5px);
}
.bottle.rainbow.glitter .body {
  background-image:
    radial-gradient(circle at 30% 30%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 70% 55%, #fff 0 1.5px, transparent 2.5px),
    linear-gradient(#ff3b3b, #ff9b1f, #ffd51f, #2cc84d, #1f6bff, #8c4dff);
}
