/* ═══════════════════════════════════════════════════════════════
   COLORING GOODS — a copy of the colouring app Sienna likes.
   White, hand-lettered, black-outlined pills. Everything lives under .cg so
   none of it leaks into Roar Battle, and none of Roar's leaks in.
   ═══════════════════════════════════════════════════════════════ */

.cg {
  --cg-ink: #111;
  --cg-soft: #6f6f6f;
  --cg-line: #d9d9d9;
  --cg-paper: #ffffff;
  --cg-stage: #f0f0f0;
  --cg-yellow: #ffe76a;
  --cg-purple: #b48cff;
  --cg-pink: #ff8fb8;
  --cg-caps: "Gochi Hand", "Chalkboard SE", "Comic Sans MS", "Marker Felt", cursive;
  --cg-hand: "Patrick Hand", "Chalkboard SE", "Comic Sans MS", cursive;
  --cg-col: 560px;          /* the content column, as on the iPad */

  position: fixed; inset: 0; z-index: 120;
  background: var(--cg-paper);
  color: var(--cg-ink);
  font-family: var(--cg-hand);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.cg * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
.cg :where(button) { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
.cg [hidden] { display: none !important; }
.cg canvas, .cg img { display: block; }

/* ── the shell: header, a scrolling page, the bar along the bottom ── */

.cg-app { position: absolute; inset: 0; display: flex; flex-direction: column; }

.cg-head {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 8px;
  max-width: calc(var(--cg-col) + 32px); width: 100%; margin: 0 auto;
}
.cg-exit {
  flex: none;
  font-family: var(--cg-caps); font-size: 15px; letter-spacing: .04em;
  border: 2px solid var(--cg-ink); border-radius: 999px;
  padding: 4px 10px 3px; line-height: 1; background: #fff;
}
.cg-exit:active { background: var(--cg-yellow); }
.cg-logo {
  flex: 1; min-width: 0;
  font-family: var(--cg-caps); font-size: 30px; line-height: 1;
  white-space: nowrap; letter-spacing: -.01em;
  padding-left: 4px;
}
.cg-logo b { font-weight: 400; background: linear-gradient(transparent 55%, var(--cg-yellow) 55%, var(--cg-yellow) 92%, transparent 92%); }
.cg-logo sup { font-size: 9px; vertical-align: top; position: relative; top: -2px; }
.cg-logo small { font-size: 15px; }
.cg-signin {
  flex: none; display: flex; align-items: center; gap: 8px;
  font-family: var(--cg-caps); font-size: 16px; letter-spacing: .04em;
}
.cg-signin span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--cg-line); background: #fff center/cover no-repeat;
  position: relative; overflow: hidden;
}
.cg-avatar:not(.has-face)::before {       /* a head and shoulders, drawn */
  content: ""; position: absolute; left: 50%; top: 8px; width: 14px; height: 14px;
  margin-left: -7px; border-radius: 50%; border: 2px solid #999;
}
.cg-avatar:not(.has-face)::after {
  content: ""; position: absolute; left: 50%; top: 24px; width: 26px; height: 26px;
  margin-left: -13px; border-radius: 50%; border: 2px solid #999;
}

.cg-pages { flex: 1; min-height: 0; position: relative; }
.cg-page {
  position: absolute; inset: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 6px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: none;
}
.cg-page.is-on { display: block; }
.cg-col { max-width: var(--cg-col); margin: 0 auto; }

/* the bar: five icons, the open one tinted */
.cg-nav {
  flex: none;
  display: flex; justify-content: space-around; align-items: flex-end;
  max-width: calc(var(--cg-col) + 32px); width: 100%; margin: 0 auto;
  padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: #fff;
}
.cg-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 72px;
  font-family: var(--cg-caps); font-size: 14px; letter-spacing: .06em;
}
.cg-nav svg { width: 42px; height: 42px; fill: none; stroke: var(--cg-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cg-nav svg .fill { fill: #fff; }
.cg-nav button.is-on svg .fill { fill: var(--cg-yellow); }
.cg-nav button.is-on svg .heart { fill: var(--cg-purple); stroke: var(--cg-purple); }
.cg-nav button.is-on svg .star { fill: var(--cg-yellow); }

/* ── pills, the one shape everything is ───────────────────────── */

.cg-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--cg-caps); font-size: 19px; letter-spacing: .04em; line-height: 1;
  border: 2px solid var(--cg-line); border-radius: 18px; background: #fff;
  padding: 11px 18px 9px; min-height: 46px;
  box-shadow: 0 1px 0 #e6e6e6;
}
.cg-pill.is-on, .cg-pill--ink { border-color: var(--cg-ink); box-shadow: 0 2px 0 var(--cg-ink); }
.cg-pill:active { transform: translateY(1px); }
.cg-pill--sq { padding: 0; width: 46px; }
.cg-pill svg { width: 22px; height: 22px; fill: none; stroke: #555; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ── HOME ─────────────────────────────────────────────────────── */

.cg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cg-tile {
  position: relative; aspect-ratio: 1; border-radius: 16px; overflow: hidden;
  background: #fafafa; text-align: center;
}
.cg-tile canvas, .cg-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cg-tile--line { border: 2px solid var(--cg-ink); background: #fff; display: flex; align-items: center; justify-content: center; }
.cg-tile--line b { font-weight: 400; font-size: 36px; }
.cg-tile--text { background: #fafafa; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 22px 14px 0; gap: 12px; }
.cg-tile--text p { margin: 0; font-size: 27px; line-height: 1.12; }
.cg-tile--text .cg-tiktok { width: 72px; height: 72px; border-radius: 50%; background: #111; display: flex; align-items: center; justify-content: center; flex: none; }
.cg-tile--text .cg-tiktok svg { width: 40px; height: 40px; }
.cg-badge {
  position: absolute; left: 8px; bottom: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border-radius: 10px; padding: 6px 10px 4px;
  font-family: var(--cg-caps); font-size: 16px; letter-spacing: .04em;
}
.cg-badge svg { width: 18px; height: 18px; fill: #ff5c7a; }

/* ── the rainbow wheel ────────────────────────────────────────── */

.cg-picker { padding-top: 22px; }
.cg-picker h2 { margin: 0 0 14px; }
.cg-wheel-wrap { position: relative; width: 220px; height: 220px; margin: 0 auto 16px; touch-action: none; }
.cg-wheel { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #e4e4e4; }
.cg-wheel-dot, .cg-light-dot {
  position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 0 2px #333; pointer-events: none;
}
.cg-light { position: relative; height: 30px; border-radius: 999px; margin: 0 6px 16px; touch-action: none; box-shadow: 0 0 0 2px #e4e4e4; }
.cg-light-dot { top: 50%; }
.cg-preview { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 18px; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #e4e4e4; }
.cg-picker .cg-dlg-row .cg-pill { font-size: 30px; }

/* ── GALLERY ──────────────────────────────────────────────────── */

.cg-tabs { display: flex; gap: 10px; margin: 2px 0 26px; }
.cg-tabs .cg-pill { flex: 1; font-size: 22px; }
.cg-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 22px; }
.cg-card { display: flex; flex-direction: column; gap: 10px; }
.cg-card-img {
  width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #fff;
  border: 1px solid #ececec;
}
.cg-card-img img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.cg-card-row { display: flex; gap: 6px; align-items: center; }
.cg-card-row .cg-pill { padding: 0; height: 44px; min-height: 44px; }
.cg-card-row .cg-pill--sq { width: 44px; }
.cg-card-row .cg-share { flex: 1; border-color: var(--cg-ink); font-size: 17px; }
.cg-card-row .cg-share svg { stroke: var(--cg-ink); width: 20px; height: 20px; }
.cg-empty { text-align: center; color: var(--cg-soft); font-size: 22px; padding: 50px 20px; line-height: 1.3; }
.cg-empty .cg-pill { margin-top: 14px; }

/* ── COLOR (the pages to colour in) ───────────────────────────── */

.cg-h { font-family: var(--cg-caps); font-size: 24px; letter-spacing: .04em; margin: 4px 0 14px; }
.cg-pics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.cg-pic { aspect-ratio: 100/130; border: 2px solid var(--cg-line); border-radius: 14px; overflow: hidden; background: #fff; position: relative; }
.cg-pic canvas { width: 100%; height: 100%; }
.cg-pic.is-done::after { content: "✓"; position: absolute; right: 6px; top: 4px; font-family: var(--cg-caps); color: #2ab15a; font-size: 22px; }

/* ── FEED ─────────────────────────────────────────────────────── */

.cg-post { border: 2px solid var(--cg-line); border-radius: 18px; overflow: hidden; margin-bottom: 18px; background: #fff; }
.cg-post-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.cg-post-head .cg-avatar { width: 36px; height: 36px; }
.cg-post-head b { font-family: var(--cg-caps); font-weight: 400; font-size: 18px; letter-spacing: .03em; }
.cg-post-head small { color: var(--cg-soft); font-size: 15px; margin-left: auto; }
.cg-post img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-top: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0; }
.cg-post-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.cg-like { display: inline-flex; align-items: center; gap: 6px; font-family: var(--cg-caps); font-size: 18px; }
.cg-like svg { width: 28px; height: 28px; fill: none; stroke: var(--cg-ink); stroke-width: 2.2; }
.cg-like.is-on svg { fill: #ff5c7a; stroke: #ff5c7a; }
.cg-like.is-on svg { animation: cgPop .3s cubic-bezier(.2,1.6,.4,1); }
@keyframes cgPop { from { transform: scale(.6) } to { transform: none } }

/* ── SETTINGS ─────────────────────────────────────────────────── */

.cg-set { display: flex; flex-direction: column; gap: 12px; }
.cg-set .cg-pill { justify-content: space-between; font-size: 20px; padding: 12px 18px 10px; }
.cg-set .cg-pill span { color: var(--cg-soft); font-family: var(--cg-hand); font-size: 18px; letter-spacing: 0; }
.cg-set p { margin: 4px 4px 0; color: var(--cg-soft); font-size: 18px; line-height: 1.3; }
.cg-set .cg-pill--warn { border-color: #ff8fb8; color: #d2306a; }

/* ── the dialog (GO BACK HOME? NO / YES) ──────────────────────── */

.cg-dim { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.cg-dialog {
  width: 100%; max-width: 360px; background: #fff; border-radius: 28px;
  padding: 36px 24px 30px; text-align: center;
  animation: cgIn .22s cubic-bezier(.2,1.3,.4,1);
}
@keyframes cgIn { from { transform: scale(.85); opacity: 0 } to { transform: none; opacity: 1 } }
.cg-dialog .cg-dlg-icon { height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.cg-dialog .cg-dlg-icon svg { width: 110px; height: 110px; fill: #6d6d6d; stroke: #6d6d6d; stroke-width: 0; }
.cg-dialog .cg-dlg-icon .arrow { width: 60px; height: 40px; fill: none; stroke: #6d6d6d; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.cg-dialog h2 { font-family: var(--cg-caps); font-weight: 400; font-size: 26px; letter-spacing: .04em; margin: 18px 0 24px; }
.cg-dialog .cg-dlg-row { display: flex; gap: 14px; justify-content: center; }
.cg-dialog .cg-dlg-row .cg-pill { flex: 1; max-width: 130px; font-size: 40px; padding: 10px 8px 6px; border: 3px solid var(--cg-ink); border-radius: 22px; box-shadow: none; }
.cg-dialog .cg-field {
  width: 100%; font: inherit; font-size: 24px; text-align: center;
  border: 2px solid var(--cg-ink); border-radius: 16px; padding: 10px; margin: 0 0 16px; background: #fff;
}
.cg-faces { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 20px; }
.cg-faces button { aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; background: center/cover no-repeat; }
.cg-faces button.is-on { border-color: var(--cg-ink); }

.cg-toast {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 110px); z-index: 40;
  transform: translateX(-50%) translateY(20px);
  background: #111; color: #fff; border-radius: 999px; padding: 10px 20px 8px;
  font-family: var(--cg-caps); font-size: 18px; letter-spacing: .04em;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.cg-toast.is-on { opacity: 1; transform: translateX(-50%); }

/* ── THE CANVAS (the editor) ──────────────────────────────────── */

.cg-editor { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; background: #fff; }
.cg-ed-top {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px;
}
.cg-ed-top .cg-pill--sq { width: 52px; min-height: 52px; border-radius: 16px; }
.cg-ed-top .cg-pill--sq svg { width: 26px; height: 26px; }
.cg-ed-top .cg-pill--sq:disabled { opacity: .35; }
.cg-ed-top .cg-save { margin-left: auto; font-family: var(--cg-hand); font-size: 24px; letter-spacing: 0; padding: 8px 20px 6px; border-radius: 16px; min-height: 52px; }
.cg-ed-top .cg-save svg { width: 24px; height: 24px; stroke: #4dc35a; stroke-width: 3.5; }

.cg-stage { flex: 1; min-height: 0; position: relative; background: var(--cg-stage); touch-action: none; }
.cg-stage canvas {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.04);
}
.cg-stage .cg-lines { pointer-events: none; background: transparent; box-shadow: none; }

/* colours: the four sizes on the left, the strip of markers on the right */
.cg-ed-colours { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; height: 118px; }
.cg-sizes { flex: none; width: 128px; height: 100%; position: relative; }
.cg-size {
  position: absolute; border-radius: 50%; background: #d8d8d8;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.04);
}
.cg-size.is-on { background: var(--cg-cur, #fff); box-shadow: 0 0 0 3px #fff, 0 0 0 5px #dcdcdc; }
.cg-size[data-size="3"] { left: 6px; top: 6px; width: 50px; height: 50px; }
.cg-size[data-size="2"] { left: 86px; top: 12px; width: 36px; height: 36px; }
.cg-size[data-size="1"] { left: 14px; top: 66px; width: 26px; height: 26px; }
.cg-size[data-size="0"] { left: 96px; top: 70px; width: 16px; height: 16px; }
.cg-strip {
  flex: 1; min-width: 0; height: 100%;
  display: flex; align-items: center; gap: 10px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  border: 1px solid #e4e4e4; border-radius: 12px; padding: 0 14px; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.cg-strip::-webkit-scrollbar { display: none; }
.cg-swatch { flex: none; width: 68px; height: 68px; border-radius: 50%; border: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); position: relative; }
.cg-swatch.is-on { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #d0d0d0; }
.cg-swatch--wheel { background: conic-gradient(from 90deg, #ff4d4d, #ffb14d, #f2ff4d, #4dff88, #4dfff6, #4d8bff, #b84dff, #ff4dd2, #ff4d4d); }
.cg-swatch--wheel::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.55), transparent 60%); }

/* tools */
.cg-ed-tools { flex: none; padding: 6px 10px calc(env(safe-area-inset-bottom, 0px) + 10px); }
.cg-tools {
  display: flex; align-items: center; gap: 6px; height: 100px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  border: 1px solid #e4e4e4; border-radius: 14px; padding: 0 10px; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.cg-tools::-webkit-scrollbar { display: none; }
.cg-tool { flex: none; width: 92px; height: 86px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.cg-tool svg { width: 64px; height: 64px; }
.cg-tool.is-on { background: #f3f3f3; box-shadow: inset 0 0 0 2px #e0e0e0; }
.cg-tool--set { width: 96px; }

/* ── bigger phones get a slightly bigger page; small ones, smaller chrome ── */
@media (max-width: 400px) {
  .cg-logo { font-size: 26px; }
  .cg-nav button { width: 62px; font-size: 12px; }
  .cg-nav svg { width: 36px; height: 36px; }
  .cg-tabs .cg-pill { font-size: 19px; padding: 10px 6px 8px; }
  .cg-ed-colours { height: 96px; }
  .cg-sizes { width: 104px; }
  .cg-size[data-size="3"] { width: 42px; height: 42px; }
  .cg-size[data-size="2"] { left: 66px; top: 8px; width: 30px; height: 30px; }
  .cg-size[data-size="1"] { top: 56px; width: 22px; height: 22px; }
  .cg-size[data-size="0"] { left: 76px; top: 60px; width: 14px; height: 14px; }
  .cg-swatch { width: 54px; height: 54px; }
  .cg-tools { height: 84px; }
  .cg-tool { width: 76px; height: 72px; }
  .cg-tool svg { width: 52px; height: 52px; }
  .cg-ed-top .cg-pill--sq { width: 46px; min-height: 46px; }
  .cg-ed-top .cg-save { font-size: 21px; min-height: 46px; }
}
