/* Promise Pals creative play. Solid storybook colors, large tap targets, no motion required. */

.screen.creative {
  width: min(1180px, 100%);
  min-height: 100dvh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--paper, #fffaf2);
}
.screen.creative > .sheet.plain.csheet {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  max-height: none;
  padding: 8px 12px calc(12px + var(--safe-b, 0px));
  -webkit-overflow-scrolling: touch;
}
.screen.creative.album {
  height: auto;
  max-height: none;
  overflow: visible;
  min-height: 100dvh;
}
.screen.creative.album > .sheet.plain.csheet {
  overflow: visible;
}

.chint {
  margin: 0 0 8px;
  text-align: center;
  color: #3a2a22;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.35;
}
.cchosen {
  margin: 0 0 6px;
  text-align: center;
  font: 700 16px/1.3 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  color: #3a2a22;
}
.cfine {
  margin: 4px 0 8px;
  text-align: center;
  color: #3a2a22;
  font-weight: 700;
  font-size: 16px;
}
.cstatus {
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: 16px;
  background: #14645d;
  color: #fff;
  text-align: center;
  font: 700 16px/1.35 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
}
.cstatus.quiet { background: transparent; color: transparent; padding: 0; min-height: 0; }
.csplit { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cmain, .cside { min-width: 0; }

.ctabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 8px;
}
.ctab {
  min-height: 48px;
  min-width: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #3a2a22;
  box-shadow: 0 4px 0 #e8c9ae;
  font: 700 16px/1.2 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
}
.ctab.on { background: #1f7f76; color: #fff; box-shadow: 0 4px 0 #14645d; }
.ctab:focus-visible, .cbtn:focus-visible, .cswatch:focus-visible, .ctile:focus-visible, .creg:focus-visible, .cpiece:focus-visible {
  outline: 3px solid #14645d;
  outline-offset: 3px;
}

.cframe.lineart { aspect-ratio: 3 / 4; width: min(100%, calc(62dvh * 0.75), 520px); }
.linepage { position: relative; width: 100%; height: 100%; }
.linecanvas { width: 100%; height: 100%; display: block; touch-action: manipulation; background: #fffdf8; }
.linewait {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  text-align: center;
  color: #3a2a22;
  background: #fffdf8;
  font: 700 16px/1.35 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
}
.linepage.is-ready .linewait,
.linepage[data-state="ready"] .linewait { display: none; }
.linewait .cbtn { min-height: 44px; min-width: 44px; }
.athumb .linewait { font-size: 11px; line-height: 1.2; padding: 4px; }
.cparts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 0; }
.cframebox { min-width: 0; }
.cpagepick, .cpartpick { display: none; }
.screen.colorplay .cparts { display: none; }
.screen.colorplay .cpalette { display: flex; align-items: center; gap: 8px; min-width: 0; }
.screen.colorplay .cpalette .cchosen { flex: 0 0 auto; margin: 0; text-align: left; white-space: nowrap; }
.screen.colorplay .cswatches {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 8px;
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 8px 18px 8px 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
}
.screen.colorplay .cswatches::-webkit-scrollbar { height: 0; display: none; }
.screen.colorplay .cswatches.more {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent);
}
.screen.colorplay .cswatch {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  aspect-ratio: auto;
  scroll-snap-align: start;
  touch-action: pan-x;
}
.screen.colorplay.parts .cpartpick {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  margin: 0;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: #3a2a22;
  box-shadow: 0 4px 0 #e8c9ae;
  font: 700 16px/1.2 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  padding: 8px 10px;
}
body.big .screen.colorplay .cswatch { flex-basis: 56px; width: 56px; height: 56px; min-width: 56px; min-height: 56px; }
/* Phone: page menu only. The part menu stays in Settings until a child needs it. */
@media (max-width: 899px) {
  .screen.colorplay { height: 100svh; max-height: 100svh; overflow: hidden; width: 100%; max-width: 100%; }
  .screen.colorplay > .sheet.plain.csheet { overflow: hidden; display: flex; flex-direction: column; min-height: 0; padding: 6px 8px 6px; }
  .screen.colorplay .chint { margin: 0 0 4px; font-size: 16px; }
  .screen.colorplay .csplit { flex: 1 1 auto; min-height: 0; min-width: 0; gap: 4px; display: flex; flex-direction: column; }
  .screen.colorplay .cmain { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; }
  .screen.colorplay .ctabs { display: none; }
  .screen.colorplay .cpicks { display: grid; grid-template-columns: 1fr; gap: 6px; width: 100%; margin: 0 0 4px; }
  .screen.colorplay .cpagepick {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 44px;
    margin: 0;
    border: 0;
    border-radius: 16px;
    background: #fff;
    color: #3a2a22;
    box-shadow: 0 4px 0 #e8c9ae;
    font: 700 16px/1.2 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
    padding: 8px 8px;
  }
  .screen.colorplay .cframebox { flex: 1 1 0; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; container-type: size; }
  .screen.colorplay .cframe,
  .screen.colorplay .cframe.lineart {
    width: min(100cqi, calc(100cqb * 0.75));
    height: auto;
    max-height: 100cqb;
    max-width: 100%;
    margin: 0;
  }
  .screen.colorplay .cparts { display: none; }
  .screen.colorplay .cside { flex: 0 0 auto; min-width: 0; max-width: 100%; }
  .screen.colorplay .ctools {
    display: grid;
    grid-template-columns: repeat(5, minmax(44px, 1fr));
    width: 100%;
    max-width: 100%;
    gap: 6px;
  }
  .screen.colorplay .cbtn { min-width: 44px; min-height: 44px; width: 100%; padding: 8px 2px; font-size: 15px; }
  .screen.colorplay .cfine { display: none; }
  .screen.colorplay .cstatus { margin: 2px 0 0; padding: 2px 8px; }
  .screen.colorplay .cstatus.quiet { display: none; }
}
@media (max-width: 899px) and (max-height: 740px) {
  .screen.colorplay .chint {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}
.cpart { min-height: 44px; min-width: 44px; padding: 8px 12px; border: 0; border-radius: 999px; background: #fff; color: #3a2a22; box-shadow: 0 4px 0 #e8c9ae; font: 700 16px/1.2 "Fredoka", "Trebuchet MS", system-ui, sans-serif; }
.cpart:focus-visible { outline: 3px solid #14645d; outline-offset: 3px; }
.cframe {
  width: min(100%, calc(58dvh * 400 / 540), 560px);
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 400 / 540;
  background: #fffdf8;
  border-radius: 22px;
  box-shadow: 0 8px 0 #e8c9ae;
  overflow: hidden;
}
.colorpage { width: 100%; height: 100%; display: block; touch-action: manipulation; background: #fffdf8; }
.cstroke { fill: none; stroke: #2a211c; stroke-width: 2.6px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.cdetail { fill: none; stroke: #2a211c; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.cink { stroke: none; pointer-events: none; }
.creg { cursor: pointer; }

.cswatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 8px;
}
.cswatch {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 3px 0 rgba(58, 42, 34, .18);
  padding: 0;
}
.cswatch.paper { border-color: #c4b09a; }
.cswatch.on { box-shadow: 0 0 0 3px #fffdf8, 0 0 0 6px #1f7f76; }

.ctools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 4px 0;
}
.cbtn {
  min-height: 48px;
  min-width: 48px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #3a2a22;
  box-shadow: 0 4px 0 #e8c9ae;
  font: 700 16px/1.2 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
}
.cbtn.primary { background: #1f7f76; color: #fff; box-shadow: 0 4px 0 #14645d; }
.cbtn:disabled { opacity: .45; }
.cbtn:active:not(:disabled), .ctab:active, .ctile:active { transform: translateY(2px); }

.cstage {
  position: relative;
  width: 100%;
  max-height: 42dvh;
  margin: 0 auto;
  border-radius: 22px;
  overflow: hidden;
  background: #d7e4c8 center/cover no-repeat;
  box-shadow: 0 8px 0 #e8c9ae;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: contain;
}
.cstage .cbg,
.aminiscene .cbg,
.cstage canvas.stagepaint,
.aminiscene canvas.stagepaint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 1;
  transform: translateZ(0);
}
.ctile img, .cpiece img {
  position: relative;
  z-index: 1;
  transform: translateZ(0);
}
.cpiece {
  position: absolute;
  width: 22%;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  touch-action: none;
  transform: translate(-50%, -50%) scale(calc(var(--s, 1) * var(--fx, 1)), var(--s, 1));
  transform-origin: center center;
}
.cpiece.feet {
  width: 17%;
  transform: translate(-50%, -100%) scale(calc(var(--s, 1) * var(--fx, 1)), var(--s, 1));
  transform-origin: center bottom;
}
.cpiece img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  background: none;
  -webkit-user-drag: none;
}
.cpiece.on { outline: 3px solid #14645d; outline-offset: 4px; border-radius: 12px; }
.cpiece.lifting { z-index: 100000 !important; }

.cnudge {
  display: grid;
  grid-template-columns: repeat(3, minmax(48px, 72px));
  grid-template-areas: ". up ." "left down right";
  gap: 8px;
  justify-content: center;
  margin: 4px auto 8px;
}
.cnudge [data-act="up"] { grid-area: up; }
.cnudge [data-act="left"] { grid-area: left; }
.cnudge [data-act="down"] { grid-area: down; }
.cnudge [data-act="right"] { grid-area: right; }

.ctray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
  padding: 8px;
  border-radius: 20px;
  background: #fff4e2;
  max-height: 30dvh;
  overflow: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.cgroup {
  flex: 1 1 100%;
  margin: 4px 0 0;
  text-align: center;
  font: 700 16px/1.2 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  color: #14645d;
}
.ctile {
  width: 76px;
  min-width: 64px;
  min-height: 88px;
  padding: 6px 4px 4px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 0 #e8c9ae;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.ctile img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: none;
  pointer-events: none;
}
.ctilename {
  font: 700 13px/1.1 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  color: #3a2a22;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.acard {
  background: #fff;
  border-radius: 22px;
  padding: 8px;
  box-shadow: 0 6px 0 #e8c9ae;
  min-width: 0;
}
.athumb {
  border-radius: 16px;
  overflow: hidden;
  background: #fffdf8;
  aspect-ratio: 4 / 5;
}
.athumb .colorpage, .athumb .linepage, .athumb .linecanvas { width: 100%; height: 100%; }
.aminiscene {
  position: relative;
  width: 100%;
  height: 100%;
  background: #d7e4c8 center/cover no-repeat;
  overflow: hidden;
}
.aministicker {
  position: absolute;
  width: 22%;
  height: auto;
  transform: translate(-50%, -50%) scale(calc(var(--s, 1) * var(--fx, 1)), var(--s, 1));
  pointer-events: none;
}
.aministicker.feet { transform: translate(-50%, -100%) scale(calc(var(--s, 1) * var(--fx, 1)), var(--s, 1)); }
.aname {
  margin: 8px 4px 4px;
  font: 700 16px/1.25 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  color: #3a2a22;
  text-align: center;
}
.aempty { text-align: center; padding: 12px 8px 24px; color: #3a2a22; }
.aempty img { width: 96px; height: 96px; object-fit: contain; margin: 8px auto; background: none; }
.aemptytitle { font: 700 1.4rem/1.2 "Fredoka", "Trebuchet MS", system-ui, sans-serif; margin: 0 0 6px; }

@media (min-width: 800px) {
  .cframe { width: min(100%, calc(62dvh * 400 / 540)); }
  .cstage { max-height: 52dvh; }
  .agrid { grid-template-columns: repeat(3, 1fr); }
  .ctray { max-height: 34dvh; }
}
@media (min-width: 900px) {
  .screen.creative:not(.album) > .sheet.plain.csheet { overflow: hidden; }
  .csplit {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
    gap: 16px;
    align-items: stretch;
    min-height: 0;
    flex: 1;
  }
  .cside { overflow: auto; min-height: 0; padding-right: 2px; }
  .cframe { width: min(100%, calc(68dvh * 400 / 540)); }
  .cstage { max-height: min(64dvh, 100%); }
  .ctray { max-height: none; }
}
@media (max-width: 389px) {
  .ctab { padding: 8px 10px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .screen.creative .cbtn,
  .screen.creative .ctab,
  .screen.creative .cswatch,
  .screen.creative .ctile,
  .screen.creative .cpiece { transition: none; animation: none; }
}
body.big .chint, body.big .cchosen, body.big .cfine, body.big .cstatus, body.big .cbtn, body.big .ctab, body.big .aname {
  font-size: 20px;
}
body.big .cbtn, body.big .ctab, body.big .cswatch { min-height: 56px; }
body.big .cswatch { width: 56px; height: 56px; }

/* Landscape split in the base app sizes every screen. Keep creative play usable inside it. */
@media (min-width: 1020px) and (orientation: landscape) {
  .screen.creative:not(.album) {
    height: calc(100dvh - 32px);
    max-height: calc(100dvh - 32px);
    min-height: 0;
  }
  .screen.creative.album {
    height: auto;
    max-height: none;
    overflow: visible;
  }
}

/* iPad only. Phones stay on the rules above. A wide desktop keeps the side column. */
@media (min-width: 700px) and (max-width: 1210px) {
  .screen.colorplay {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .screen.colorplay > .appbar { flex: 0 0 auto; }
  .screen.colorplay > .sheet.plain.csheet {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 6px 16px 10px;
  }
  .screen.colorplay .chint { margin: 0 0 6px; }
  .screen.colorplay .csplit {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    gap: 8px;
    grid-template-columns: none;
  }
  .screen.colorplay .cmain {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
  }
  .screen.colorplay .ctabs { display: none; }
  .screen.colorplay .cpicks { display: block; width: min(420px, 100%); margin: 0 auto 6px; }
  .screen.colorplay .cpagepick {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    margin: 0;
    border: 0;
    border-radius: 16px;
    background: #fff;
    color: #3a2a22;
    box-shadow: 0 4px 0 #e8c9ae;
    font: 700 18px/1.2 "Fredoka", "Trebuchet MS", system-ui, sans-serif;
    padding: 8px 12px;
  }
  .screen.colorplay .cframebox {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    container-type: size;
  }
  .screen.colorplay .cframe,
  .screen.colorplay .cframe.lineart {
    width: min(100cqi, calc(100cqb * 0.75));
    height: auto;
    aspect-ratio: 3 / 4;
    max-height: 100cqb;
    max-width: 100%;
    margin: 0;
  }
  .screen.colorplay .cside {
    flex: 0 0 auto;
    overflow: visible;
    min-width: 0;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
  }
  .screen.colorplay .cpalette { justify-content: center; }
  .screen.colorplay .cswatches {
    justify-content: center;
    flex: 0 1 auto;
    overflow: visible;
    mask-image: none;
    -webkit-mask-image: none;
  }
  .screen.colorplay .cswatch {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
  }
  .screen.colorplay .ctools {
    display: grid;
    grid-template-columns: repeat(5, minmax(52px, 1fr));
    gap: 8px;
    width: 100%;
  }
  .screen.colorplay .cbtn { min-width: 52px; min-height: 52px; font-size: 18px; }
  .screen.colorplay .cstatus { margin: 0; padding: 4px 10px; }
  .screen.colorplay .cfine { display: none; }
}
@media (min-width: 700px) and (max-width: 900px) {
  .screen.colorplay .cswatch {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
}
@media (min-width: 700px) and (max-width: 1210px) and (max-height: 860px) {
  .screen.colorplay .chint {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .screen.colorplay > .sheet.plain.csheet { padding: 4px 12px 6px; }
  .screen.colorplay .csplit { gap: 4px; }
  .screen.colorplay .cswatch {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
  .screen.colorplay .cbtn { min-height: 48px; min-width: 48px; }
}
