/* ============ Colorkins — soft pastel kid UI (compact) ============ */
:root {
  --cream: #FFF8EC;
  --paper: #FFFFFF;
  --ink: #3a3a3a;
  --accent: #f4652f;
  --accent2: #ffb84d;
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "Baloo 2", "Nunito", "Segoe UI Rounded", sans-serif;
  background: var(--cream);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}
button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(58,58,58,.12);
  transition: transform .08s ease;
}
button:active { transform: scale(.93); }

.screen { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.hidden { display: none !important; }

/* ============ GALLERY (compact) ============ */
#gallery {
  padding: max(10px, env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom));
  text-align: center;
}
.brand { margin-bottom: 6px; }
.brand .coco { display: flex; justify-content: center; }
.brand .coco svg { width: 36px; height: 36px; }
.brand h1 { font-size: 26px; margin: 0; letter-spacing: .5px; }
.brand .kins { color: var(--accent); }
.brand .sub { margin: 0 0 2px; font-size: 12px; opacity: .6; }

.addbtn {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ffe9d6;
  color: var(--accent);
  box-shadow: 0 2px 0 rgba(58,58,58,.1);
}

/* category tabs */
.cats {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  margin: 6px auto 8px; max-width: 700px;
}
.catab {
  display: flex; flex-direction: column; align-items: center;
  min-width: 60px; padding: 5px 8px 3px;
  border-radius: 14px; font-size: 16px;
}
.catab small { font-size: 9px; font-weight: 800; }
.catab.sel { outline: 3px solid var(--accent2); outline-offset: -3px; background: #FFF3E0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  max-width: 680px;
  margin: 0 auto;
}
.card {
  position: relative;
  padding: 8px 6px 6px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 3px 0 rgba(58,58,58,.1);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.card svg { width: 58px; height: 64px; }
.card img.cimg { width: 58px; height: 64px; object-fit: contain; }
.card .label { font-size: 11px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .saved {
  position: absolute; top: 5px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #4caf50;
  box-shadow: 0 0 0 2px #4caf5033;
}
.card .del {
  position: absolute; top: 3px; left: 5px;
  font-size: 10px; font-weight: 900; line-height: 1;
  padding: 3px 6px; border-radius: 999px;
  background: #ffe3e0; color: #c62828;
}
.galfot { margin-top: 12px; font-size: 11px; opacity: .55; }

/* ============ STUDIO (compact) ============ */
#studio {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: max(6px, env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
  overflow: hidden;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chip { width: 42px; height: 42px; font-size: 21px; border-radius: 13px; padding: 0; }
.chip:disabled { opacity: .3; transform: none; }
.title { font-size: 15px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title .em { margin-right: 4px; }

.stagewrap { flex: 1; display: flex; justify-content: center; min-height: 100px; }
#stage {
  position: relative;
  aspect-ratio: 900 / 1100;
  width: min(96vw, calc((100dvh - 330px) * .818));
  max-width: 640px;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(120, 80, 20, .12);
  touch-action: none;
  overflow: hidden;
}
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#artC { mix-blend-mode: multiply; pointer-events: none; }

/* tools */
.toolrow { display: flex; gap: 6px; justify-content: center; flex-wrap: nowrap; }
.toolbtn {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  min-width: 44px; padding: 5px 4px 3px;
  border-radius: 12px;
  font-size: 19px;
}
.toolbtn small { font-size: 9px; font-weight: 700; }
.toolbtn.sel { outline: 3px solid var(--accent2); outline-offset: -3px; background: #FFF3E0; }

.midrow { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 38px; }
.sizerow { display: flex; gap: 6px; }
.sizebtn { width: 42px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 11px; }
.sizebtn .dot { background: var(--ink); border-radius: 50%; }
.d1 { width: 7px; height: 7px; }
.d2 { width: 12px; height: 12px; }
.d3 { width: 17px; height: 17px; }
.sizebtn.sel { outline: 3px solid var(--accent2); outline-offset: -3px; }

/* palette */
.palette {
  display: flex; flex-wrap: wrap; gap: 7px;
  justify-content: center;
  padding: 8px;
  background: rgba(255,255,255,.65);
  border-radius: var(--radius);
}
.sw {
  width: 36px; height: 36px;
  border-radius: 50%;
  padding: 0;
  border: 3px solid #ffffffcc;
  box-shadow: 0 2px 0 rgba(58,58,58,.15);
}
.sw.sel { outline: 3px solid var(--ink); outline-offset: 2px; transform: scale(1.06); }

/* action buttons */
.actions { display: flex; gap: 10px; justify-content: center; }
.softbtn, .donebtn {
  flex: 1; max-width: 250px;
  font-size: 19px; padding: 8px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.softbtn span, .donebtn span { font-size: 14px; font-weight: 800; }
.donebtn { background: #4CAF50; color: #fff; box-shadow: 0 3px 0 rgba(46,104,49,.4); }
.softbtn { background: #FFE9D6; }

/* fx + bravo */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.bravo {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; z-index: 70;
  font-size: 22px; font-weight: 800;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 6px #fff, 0 4px 14px rgba(0,0,0,.08);
}
.bravo .big { font-size: 64px; }
.bravo.show { animation: pop 2s ease forwards; }
@keyframes pop {
  0% { opacity: 0; transform: scale(.6); }
  15% { opacity: 1; transform: scale(1.1); }
  30% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* modal */
.modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(58,45,20,.35);
  display: flex; align-items: center; justify-content: center;
}
.modal .card {
  background: #fff; border-radius: 22px;
  padding: 20px 24px; text-align: center;
  box-shadow: 0 12px 40px rgba(58,45,20,.25);
}
.modal .mascot { font-size: 42px; margin-bottom: 2px; }
.modal p { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
.mrow { display: flex; gap: 10px; }
.mbtn { flex: 1; font-size: 16px; font-weight: 800; padding: 10px 18px; }
.mbtn.yes { background: #4CAF50; color: #fff; }
.mbtn.no { background: #FFE9D6; }

/* "add to home screen" banner */
#a2hs {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 90;
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 8px 30px rgba(58,45,20,.3);
  animation: rise .35s ease;
  cursor: pointer;          /* whole banner is a tap target */
}
@keyframes rise {
  from { transform: translateY(70px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
#a2hs .a2hsEmoji { font-size: 24px; }
#a2hs .a2hsText { flex: 1; font-size: 12.5px; font-weight: 700; line-height: 1.4; color: var(--ink); }
#a2hs .a2hsTitle { font-size: 13.5px; }
#a2hsAdd {
  background: #4CAF50; color: #fff;
  font-size: 13px; font-weight: 800; padding: 9px 16px;
  border-radius: 999px; white-space: nowrap;
}
#a2hsShare {
  background: #29b6f6; color: #fff;
  font-size: 13px; font-weight: 800; padding: 9px 16px;
  border-radius: 999px; white-space: nowrap;
}
#a2hsClose {
  width: 30px; height: 30px; border-radius: 999px;
  background: #FFE9D6; font-size: 13px; font-weight: 900; color: var(--ink);
}
