/* Candy Cuddle Kids — Coloring Studio (scoped to .g-color) */
.g-color { --cur: #e0245e; }
.g-color .gc-bar { align-items: center; }
.g-color .gc-title { font-size: clamp(1.15rem, 2.4vw, 1.5rem); margin: 0; color: var(--berry-dark); }
.g-color .gc-ico { display: inline-grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; }
.g-color .gc-ico svg { width: 100%; height: 100%; display: block; overflow: visible; }
.g-color .ic-c { fill: var(--cur); transition: fill .2s; }
.g-color .icon-btn .gc-ico { width: 26px; height: 26px; }
.g-color .icon-btn[disabled] { opacity: .4; cursor: default; box-shadow: inset 0 0 0 2px var(--line); }
.g-color .gc-save .gc-ico { width: 22px; height: 22px; }

/* page picker */
.g-color .gc-pages { display: flex; gap: 10px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; padding: 4px 4px 12px; margin: 0 -4px 6px; scrollbar-width: thin; }
.g-color .gc-page { position: relative; flex: 0 0 auto; width: 104px; height: 82px; padding: 6px; border: 0; border-radius: 16px; background: #fff; cursor: pointer; scroll-snap-align: start; box-shadow: inset 0 0 0 3px var(--line); transition: transform .15s, box-shadow .15s; }
.g-color .gc-page img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.g-color .gc-page:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 3px var(--berry-soft), var(--shadow-sm); }
.g-color .gc-page[aria-pressed="true"] { box-shadow: inset 0 0 0 4px var(--berry), var(--shadow-sm); background: var(--berry-soft); }
.g-color .gc-page-badge { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: var(--ink); font-size: .9rem; line-height: 26px; text-align: center; box-shadow: 0 2px 0 var(--gold-dark); display: none; }
.g-color .gc-page.has-work .gc-page-badge { display: block; }

/* layout */
.g-color .gc-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.g-color .gc-stagewrap { display: flex; justify-content: center; min-width: 0; }
.g-color .gc-stage {
  position: relative; width: min(100%, max(300px, calc((100vh - 150px) * var(--arn, 1)))); aspect-ratio: var(--ar, 1 / 1);
  border: 3px solid var(--line); border-radius: 20px; overflow: hidden; background: #fff;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cpath d='M16 3C16 3 6 15 6 21a10 10 0 0 0 20 0C26 15 16 3 16 3Z' fill='%23ffc94d' stroke='%233c1e23' stroke-width='2.5'/%3E%3Ccircle cx='12' cy='20' r='2.5' fill='%23fff'/%3E%3C/svg%3E") 16 30, crosshair;
}
.g-color .gc-stage:not([data-tool="fill"]) { cursor: none; }
.g-color .gc-stage:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.g-color .gc-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.g-color .gc-stage .gc-lines { pointer-events: none; }
.g-color .gc-hover { position: absolute; left: 0; top: 0; width: var(--d, 20px); height: var(--d, 20px); margin: calc(var(--d, 20px) / -2) 0 0 calc(var(--d, 20px) / -2); border-radius: 50%; border: 2px solid rgba(60, 30, 35, .7); box-shadow: 0 0 0 2px rgba(255, 255, 255, .8); pointer-events: none; opacity: 0; z-index: 3; }
.g-color .gc-hover.is-on { opacity: 1; }
.g-color .gc-kcursor { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 4px solid var(--berry); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); pointer-events: none; display: none; z-index: 3; }
.g-color .gc-kcursor::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--ink); }
.g-color .gc-stage:focus-visible .gc-kcursor { display: block; }
.g-color .gc-loading { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; background: rgba(255, 255, 255, .92); font-family: var(--head); font-weight: 600; color: var(--ink-soft); z-index: 4; text-align: center; padding: 16px; }
.g-color .gc-loading[hidden] { display: none; }
.g-color .gc-spin { width: 46px; height: 46px; border-radius: 50%; border: 6px solid var(--berry-soft); border-top-color: var(--berry); animation: gcSpin .9s linear infinite; }
@keyframes gcSpin { to { transform: rotate(360deg); } }

.g-color .gc-burst { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 2; }
.g-color .gc-burst i { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; background: var(--gold); clip-path: polygon(50% 0, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%); transform: rotate(var(--a)) translateY(0); animation: gcBurst .65s cubic-bezier(.2, .8, .3, 1) forwards; }
.g-color .gc-burst i:nth-child(odd) { background: #fff; filter: drop-shadow(0 0 1px rgba(60, 30, 35, .6)); }
@keyframes gcBurst { to { transform: rotate(var(--a)) translateY(-44px) scale(.3); opacity: 0; } }

/* panel */
.g-color .gc-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.g-color .gc-tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.g-color .gc-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 66px; padding: 6px 2px; border: 0; border-radius: 16px; background: var(--cream); box-shadow: inset 0 0 0 2px var(--line); color: var(--ink); cursor: pointer; font-family: var(--head); font-weight: 600; font-size: .78rem; transition: transform .15s, box-shadow .15s, background .15s; }
.g-color .gc-tool .gc-ico { width: 32px; height: 32px; }
.g-color .gc-tool:hover { box-shadow: inset 0 0 0 2px var(--berry); }
.g-color .gc-tool[aria-pressed="true"] { background: var(--berry-soft); box-shadow: inset 0 0 0 3px var(--berry), 0 4px 0 var(--berry); transform: translateY(-2px); color: var(--berry-dark); }
.g-color .gc-row2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.g-color .gc-sizes { display: flex; gap: 6px; background: var(--cream); padding: 4px; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--line); transition: opacity .2s; }
.g-color .gc-sizes.is-dim { opacity: .55; }
.g-color .gc-size { width: 48px; height: 48px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; cursor: pointer; }
.g-color .gc-size span { display: block; border-radius: 50%; background: var(--ink); }
.g-color .gc-size-s span { width: 9px; height: 9px; }
.g-color .gc-size-m span { width: 17px; height: 17px; }
.g-color .gc-size-l span { width: 28px; height: 28px; }
.g-color .gc-size[aria-pressed="true"] { background: #fff; box-shadow: inset 0 0 0 3px var(--berry); }
.g-color .gc-size[aria-pressed="true"] span { background: var(--cur); box-shadow: 0 0 0 2px var(--ink); }
.g-color .gc-sizes.is-dim .gc-size[aria-pressed="true"] { box-shadow: none; background: transparent; }
.g-color .gc-curwrap { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-weight: 600; color: var(--ink-soft); min-width: 0; }
.g-color .gc-cur { width: 44px; height: 44px; border-radius: 50%; background: var(--sw, var(--berry)); box-shadow: inset 0 0 0 3px rgba(60, 30, 35, .15), 0 3px 0 rgba(60, 30, 35, .18); flex-shrink: 0; }
.g-color .gc-cur.is-rainbow { background: conic-gradient(#ff5f6d, #ffc94d, #3fbf7f, #5ab8ff, #a45cff, #ff5f6d); }
.g-color .gc-cur.is-eraser { background: #fff; box-shadow: inset 0 0 0 3px var(--ink-soft); background-image: repeating-linear-gradient(45deg, transparent 0 6px, var(--line) 6px 9px); }
.g-color .gc-cur-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .98rem; }

.g-color .gc-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.g-color .gc-sw { position: relative; width: 100%; aspect-ratio: 1; min-width: 44px; border: 0; padding: 0; border-radius: 50%; background: var(--sw, #fff); box-shadow: inset 0 0 0 2px rgba(60, 30, 35, .14), 0 3px 0 rgba(60, 30, 35, .14); cursor: pointer; transition: transform .12s; }
.g-color .gc-sw:hover { transform: translateY(-2px) scale(1.05); }
.g-color .gc-sw[aria-pressed="true"] { transform: scale(1.08); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); z-index: 1; }
.g-color .gc-sw[aria-pressed="true"]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px var(--ink); }
.g-color .gc-sw-rainbow { background: conic-gradient(#ff5f6d, #ffc94d, #3fbf7f, #5ab8ff, #a45cff, #ff5f6d); }
.g-color .gc-mix { display: grid; place-items: center; background: conic-gradient(#ff5f6d, #ffc94d, #3fbf7f, #5ab8ff, #a45cff, #ff5f6d); overflow: hidden; }
.g-color .gc-mix span { position: relative; width: 60%; height: 60%; border-radius: 50%; background: #fff; display: grid; place-items: center; font-family: var(--head); font-weight: 700; font-size: 1.3rem; line-height: 1; color: var(--ink); pointer-events: none; }
.g-color .gc-mix input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.g-color .gc-mix:focus-within { box-shadow: 0 0 0 4px var(--gold); }
.g-color .gc-h { font-size: .95rem; margin: 4px 0 -4px; color: var(--ink-soft); font-weight: 600; }
.g-color .gc-row-chars { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.g-color .gc-sw-char { overflow: visible; }
.g-color .gc-sw-char::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #fff; }
.g-color .gc-sw-char img { position: absolute; inset: 7px; width: calc(100% - 14px); height: calc(100% - 14px); object-fit: contain; pointer-events: none; }
.g-color .gc-sw-char[aria-pressed="true"]::after { left: auto; top: auto; right: -2px; bottom: -2px; transform: none; width: 14px; height: 14px; background: var(--gold); }

/* confirm + print frame (mounted inside the game root) */
.g-color .gc-confirm .cck-modal img { height: 120px; margin-top: -76px; }
.g-color .gc-confirm h2 { font-size: 1.7rem; }
.g-color .gc-printframe { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }

@media (max-width: 899px) {
  .g-color .gc-main { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .g-color .gc-stage { width: 100%; max-width: calc((100vh - 120px) * var(--arn, 1)); min-width: min(100%, 300px); }
  .g-color .gc-palette { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
}
@media (max-width: 520px) {
  .g-color .gc-bar { gap: 8px; }
  .g-color .gc-bar .group { gap: 6px; }
  .g-color .gc-save { padding: 8px 14px; }
  .g-color .gc-save span:last-child { display: none; }
  .g-color .gc-save .gc-ico { width: 26px; height: 26px; }
  .g-color .gc-tool { font-size: .7rem; min-height: 62px; }
  .g-color .gc-tool .gc-ico { width: 28px; height: 28px; }
  .g-color .gc-page { width: 88px; height: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  .g-color .gc-spin { animation: none; border-top-color: var(--berry-soft); }
}
@media print { .g-color .gc-printframe { display: none; } }
