/* Game Studio v1 — playful, big touch targets. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #f5f3ff; color: #1e1b2e;
  max-width: 900px; margin: 0 auto;
  min-height: 100vh; padding-bottom: 40px;
}
#topbar {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff; padding: 14px 18px; border-radius: 0 0 20px 20px;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 24px; font-weight: 800; }
.tagline { font-size: 13px; opacity: 0.85; }
main { padding: 14px 14px 0; }
h2 { font-size: 20px; margin: 14px 0 10px; }
.inline-h { font-size: 18px; margin: 0; }
.muted { color: #6b7280; font-size: 14px; }
.foot { text-align: center; margin-top: 26px; }

/* makers */
.makers { display: grid; grid-template-columns: 1fr; gap: 12px; }
.maker {
  display: grid; grid-template-columns: 64px 1fr; gap: 4px 14px;
  align-items: center; text-align: left;
  background: #fff; border: 3px solid #ddd6fe; border-radius: 18px;
  padding: 16px; cursor: pointer; font-size: 16px; color: inherit;
}
.maker:active { transform: scale(0.98); background: #ede9fe; }
.maker-icon { font-size: 44px; grid-row: span 2; }
.maker-name { font-size: 20px; font-weight: 800; }
.maker-desc { font-size: 14px; color: #6b7280; }

/* shelf */
.shelf-head { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.shelf-head h2 { flex: 1; }
.game-card {
  background: #fff; border: 2px solid #e5e7eb; border-radius: 16px;
  padding: 12px 14px; margin: 10px 0; display: flex;
  align-items: center; justify-content: space-between; gap: 10px;
  cursor: pointer;
}
.game-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.game-icon { font-size: 34px; }
.game-name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.game-type { font-size: 13px; color: #6b7280; }
.game-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* buttons */
.btn {
  border: 2px solid #c4b5fd; background: #fff; color: #4c1d95;
  border-radius: 14px; padding: 10px 16px; font-size: 16px; font-weight: 700;
  cursor: pointer; min-height: 48px;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.btn-danger { border-color: #fca5a5; color: #b91c1c; }
.btn.small { font-size: 14px; padding: 8px 12px; min-height: 42px; }
.btn.big { font-size: 17px; padding: 12px 20px; }
.btn.wide { width: 100%; margin: 12px 0; }
.btn:disabled { opacity: 0.4; }

/* editor bars */
.ebar { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.nameinput {
  flex: 1; min-width: 160px; font-size: 17px; padding: 10px 14px;
  border: 2px solid #c4b5fd; border-radius: 14px; min-height: 48px;
}
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.toolbtn {
  flex: 1 1 0; min-width: 100px; font-size: 15px; font-weight: 700;
  padding: 12px 6px; border-radius: 14px; border: 2px solid #c4b5fd;
  background: #fff; color: #4c1d95; cursor: pointer; min-height: 52px;
}
.toolbtn.on { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.hint { font-size: 14px; color: #6b7280; margin: 4px 0 8px; }
.hud { font-size: 18px; font-weight: 700; flex: 1; text-align: center; }

/* canvases */
.canvas-wrap {
  background: #fff; border: 3px solid #ddd6fe; border-radius: 16px;
  overflow: hidden; touch-action: none;
}
.canvas-wrap canvas { display: block; width: 100%; height: auto; }
.canvas-wrap.tall { max-width: 480px; margin: 0 auto; }
.canvas-scroll {
  background: #fff; border: 3px solid #ddd6fe; border-radius: 16px;
  overflow-x: auto; touch-action: pan-x pan-y;
}
.canvas-scroll canvas { display: block; height: 300px; width: 2400px; max-width: none; }

/* overlays */
.overlay {
  position: fixed; inset: 0; background: rgba(30, 27, 46, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.ocard {
  background: #fff; border-radius: 22px; padding: 28px; text-align: center;
  max-width: 360px; width: 100%;
}
.ocard h2 { font-size: 26px; margin: 0 0 8px; }
.ocard p { color: #6b7280; margin: 0 0 16px; }
.ocard .btn { display: block; width: 100%; margin: 8px 0; }

/* jump button */
#rpJump {
  display: block; width: 150px; height: 150px; border-radius: 50%;
  margin: 14px auto 0; font-size: 22px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: 4px solid #15803d; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
#rpJump:active { transform: scale(0.93); }

/* coloring */
.page-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.page-thumb {
  background: #fff; border: 2px solid #ddd6fe; border-radius: 14px;
  padding: 6px; cursor: pointer; font-size: 13px; font-weight: 700; color: #4c1d95;
}
.page-thumb canvas { width: 100%; height: auto; border-radius: 8px; display: block; }
.page-thumb span { display: block; margin: 4px 0 2px; }
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 10px 0; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; border: 3px solid #e5e7eb; cursor: pointer;
  min-height: 48px;
}
.swatch.on { border-color: #7c3aed; transform: scale(1.12); box-shadow: 0 0 0 3px #ddd6fe; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gal-item { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid #e5e7eb; }
.gal-item img { width: 100%; display: block; }
.gal-del {
  position: absolute; top: 4px; right: 4px; width: 34px; height: 34px;
  border-radius: 50%; border: none; background: rgba(0,0,0,0.6); color: #fff;
  font-size: 20px; cursor: pointer;
}

/* toast + lightbox */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1e1b2e; color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: 16px; font-weight: 600; z-index: 100; max-width: 90vw; text-align: center;
}
#lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }

@media (min-width: 700px) {
  .makers { grid-template-columns: 1fr 1fr 1fr; }
  .maker { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .maker-icon { grid-row: auto; }
}
