* { 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: #f4f0ff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(110% 80% at 50% 30%, #2b2350 0%, #161229 55%, #0b0915 100%);
}

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: 700;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0 16px;
  min-height: 44px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill:active { background: rgba(255, 255, 255, 0.25); }
.pill.on {
  background: rgba(140, 220, 255, 0.22);
  border-color: rgba(140, 220, 255, 0.7);
}

.big {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1.5px;
  border: none;
  border-radius: 999px;
  padding: 0 24px;
  min-height: 52px;
  color: #fff;
  background: linear-gradient(90deg, #ff4f9a, #ff9b3d, #ffd53d, #4fe08a, #3db8ff, #9b6bff);
  background-size: 200% 100%;
  box-shadow: 0 4px 18px rgba(255, 90, 170, 0.35);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  animation: shimmer 4s linear infinite;
  white-space: nowrap;
}
.big:active { transform: scale(0.96); }
@keyframes shimmer { to { background-position: 200% 0; } }

.round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}
.round:active { background: rgba(255, 255, 255, 0.3); }
.round:disabled { opacity: 0.3; }

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

#top {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
  /* the arcade's "← Rigotti Games" button sits in the top left corner */
  padding-left: 150px;
  min-height: 44px;
}
#topBtns {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
#topBtns .pill { padding: 0 12px; font-size: 12px; }
.coins {
  background: rgba(255, 200, 40, 0.16);
  border-color: rgba(255, 200, 40, 0.55);
  color: #ffe08a;
  cursor: default;
}

/* ---------- the picture ---------- */

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

#spinner {
  position: relative;
  width: 300px;
  height: 300px;
  will-change: transform;
}

#disc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg, #000);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.12),
    0 0 40px rgba(150, 110, 255, 0.35);
  transition: background 0.3s;
}

#disc canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#guides { pointer-events: none; }
#art { touch-action: none; cursor: crosshair; }

#spinHint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 1px;
  opacity: 0.6;
  pointer-events: none;
}

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

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

#spinTools {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding-bottom: 6px;
}

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

.group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.count {
  min-width: 52px;
  text-align: center;
  line-height: 1;
}
.count span {
  display: block;
  font-size: 26px;
  font-weight: 800;
}
.count small {
  font-size: 9px;
  letter-spacing: 1.5px;
  opacity: 0.7;
}

#bgDot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: var(--bg, #000);
}

#colors { gap: 6px; }

.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  padding: 0;
  position: relative;
}
.swatch.picked {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}
.swatch.rainbow {
  background: conic-gradient(red, orange, yellow, lime, cyan, blue, magenta, red);
}
.swatch.eraser {
  background: #fff;
  font-size: 18px;
  line-height: 1;
}
.swatch.eraser::after {
  content: "🧽";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.swatch.eraser { background: rgba(255, 255, 255, 0.85); }
.swatch.neon { box-shadow: 0 0 10px 2px var(--glow); }
.swatch.metal {
  background-image: linear-gradient(135deg, rgba(255,255,255,0.65) 0%, rgba(255,255,255,0) 45%, rgba(0,0,0,0.25) 100%);
}

.size {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.size.picked { border-color: #fff; background: rgba(255, 255, 255, 0.18); }
.size i {
  display: block;
  border-radius: 50%;
  background: var(--ink, #fff);
}

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

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 6, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.card {
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  overflow: auto;
  background: #1f1a3a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  touch-action: pan-y;
}
.card.small { max-width: 340px; }
.card.wide { max-width: 760px; text-align: left; }

h1 {
  margin: 0 0 4px;
  font-size: 34px;
  letter-spacing: 3px;
  background: linear-gradient(90deg, #ff4f9a, #ffd53d, #4fe08a, #3db8ff, #9b6bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h2 { margin: 0; font-size: 20px; letter-spacing: 2px; }
.tag { margin: 0 0 16px; opacity: 0.75; }
.how {
  text-align: left;
  padding-left: 20px;
  margin: 0 0 20px;
  line-height: 1.5;
}
.how li { margin-bottom: 6px; }

#confirmText { font-size: 18px; margin: 0 0 18px; }
.btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.galleryHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
#galleryEmpty { opacity: 0.75; }
#galleryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.pic {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pic img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
  cursor: pointer;
}
.pic .acts {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.pic .acts button {
  min-height: 40px;
  min-width: 40px;
  padding: 0 10px;
  font-size: 12px;
}

#toast {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  z-index: 20;
  background: #fff;
  color: #1f1a3a;
  font-weight: 800;
  font-size: 18px;
  padding: 14px 24px;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  animation: pop 0.25s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } }

/* short screens (phone held sideways): squeeze the tools */
@media (max-height: 560px) {
  .swatch { width: 30px; height: 30px; }
  .count span { font-size: 20px; }
  #tools { gap: 4px; }
}

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

.pill:disabled { opacity: 0.55; cursor: default; }
.pill.buy {
  background: rgba(255, 200, 40, 0.2);
  border-color: rgba(255, 200, 40, 0.7);
  color: #ffe08a;
}
.pill.small { min-height: 36px; padding: 0 10px; font-size: 12px; }

#sellForm { display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: left; }
#sellPreview {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  align-self: center;
  margin-top: 12px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}
#sell label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; letter-spacing: 0.5px; }
#sell input {
  font: inherit;
  font-size: 18px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  user-select: text;
  -webkit-user-select: text;
}
.askRow { display: flex; align-items: center; gap: 8px; font-weight: 700; 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.7; line-height: 1.4; }
.error { margin: 0; color: #ff8fa3; font-weight: 700; min-height: 1em; }

#sellResult { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.pixel { 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;
  color: #1f1a3a;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 700;
  line-height: 1.35;
  position: relative;
}
.soldLine { font-size: 18px; margin-bottom: 12px; }

.offline { opacity: 0.8; 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: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 10px 12px;
}
.shopLook { width: 96px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.shopLook .dot { width: 20px; height: 20px; border-radius: 50%; }
.shopLook .dot.neon { box-shadow: 0 0 8px 2px var(--glow); }
.shopLook .giantDot { width: 46px; height: 46px; background: #fff; }
.shopLook .bigNum { font-size: 30px; font-weight: 900; }
.shopWords { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.shopWords span { font-size: 13px; opacity: 0.7; }

.best {
  background: linear-gradient(135deg, rgba(255, 200, 40, 0.18), rgba(155, 107, 255, 0.18));
  border: 1px solid rgba(255, 200, 40, 0.5);
  border-radius: 20px;
  padding: 14px;
  margin-bottom: 16px;
  text-align: center;
}
.bestTag { font-weight: 900; letter-spacing: 2px; color: #ffe08a; 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;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}
.card-item.featured img { width: min(260px, 70vw); }
.itemTitle { font-weight: 800; }
.itemBy { font-size: 12px; opacity: 0.65; }
.itemSays { font-size: 14px; opacity: 0.85; max-width: 420px; }
.itemRow { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.report {
  background: none;
  border: none;
  font-size: 11px;
  opacity: 0.4;
  padding: 4px;
}
.picLabel { font-size: 12px; text-align: center; opacity: 0.8; }
.galleryHead { gap: 10px; }
.galleryHead h2 { flex: 1; }
