/* Unicorn Paint - styles. Design tokens per SPEC §5. No remote fonts (works offline). */
:root {
  --bg1: #F6EEFF;
  --bg2: #FFEAF4;
  --ink: #3D2C5A;
  --violet: #8B5CF6;
  --pink: #FF6FAE;
  --mint: #4FD1C5;
  --sun: #FFC94D;
  --lilac: #EFE4FF;
  --card: #FFFFFF;
  --radius: 24px;
  --shadow: 0 6px 18px rgba(61, 44, 90, .12);
  --shadow-sm: 0 3px 10px rgba(61, 44, 90, .12);
  --tap: 56px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  --ad-h: 50px;   /* banner strip: 50 phones / 90 tablets+desktop */
  --ad-gap: 8px;
  --current: #FF4D6D;
}
@media (min-width: 768px) and (min-height: 600px) {
  :root { --ad-h: 90px; }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
button, a.pill { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 4px solid rgba(139, 92, 246, .55); outline-offset: 3px; }
[hidden] { display: none !important; }
svg { display: block; }

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
#screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ---------- bottom banner strip (never overlaps tools/canvas) ---------- */
#ad-strip {
  flex: none;
  height: var(--ad-h);
  box-sizing: content-box;
  margin-top: var(--ad-gap);
  padding: 0 8px env(safe-area-inset-bottom);
  display: flex;
  justify-content: center;
  overflow: hidden;
}
.ad-slot { width: 100%; max-width: 728px; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ad-iframe-banner { width: 100%; height: 100%; border: 0; display: block; background: transparent; }
.ad-iframe-banner.ad-hidden { visibility: hidden; }
.ad-iframe-full { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; z-index: 5000; background: transparent; }
.ad-iframe-full.ad-hidden { opacity: 0; pointer-events: none; }
.ad-safety-close { position: fixed; top: 12px; right: 12px; z-index: 5001; font-size: 24px; }

/* ---------- buttons ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 0 22px;
  border: 0; border-radius: 999px;
  background: var(--card); color: var(--ink);
  font-size: 18px; font-weight: 800; text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, background .15s;
}
.pill:active { transform: scale(.96); }
.pill.primary { background: var(--violet); color: #fff; }
.pill.ghost { background: transparent; box-shadow: none; }
.pill.wide { width: 100%; }
.pill.big { min-height: 64px; font-size: 20px; padding: 0 26px; }
.pill:disabled { opacity: .55; transform: none; }
.emo { font-size: 24px; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.icon svg { width: 24px; height: 24px; }

.icon-btn {
  flex: none;
  width: var(--tap); height: var(--tap);
  border: 0; border-radius: 50%;
  background: var(--card); color: var(--ink);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, opacity .15s;
}
.icon-btn svg { width: 28px; height: 28px; }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; }

/* ---------- boot ---------- */
.boot { flex: 1; display: grid; place-items: center; }
.boot-title { font-size: 40px; font-weight: 900; color: var(--violet); }
.noscript { text-align: center; padding: 40px; font-size: 20px; }

/* ---------- home ---------- */
.home-screen, .gallery-screen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 28px;
}
.home-header { text-align: center; }
.app-title {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 8px 0 14px;
  font-size: clamp(36px, 8vw, 60px); font-weight: 900; letter-spacing: -.5px;
  background: linear-gradient(90deg, var(--violet), var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title-sparkle { -webkit-text-fill-color: initial; color: initial; font-size: .7em; animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 50% { transform: scale(1.2) rotate(12deg); opacity: .8; } }
.home-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 0 auto 18px; max-width: 980px; }
.pill.action { padding: 0 20px 0 16px; }
.sparkle-btn.unlocked { background: linear-gradient(90deg, #FFF3B0, #FFE4EF); }
.parents-btn { background: var(--lilac); }
.offline-banner {
  width: calc(100% - 8px); max-width: 560px; margin: 0 auto 18px; padding: 14px 20px;
  border-radius: 22px; background: var(--card); box-shadow: var(--shadow);
  text-align: center; font-size: 18px;
}
.home-sections { width: 100%; max-width: 1200px; margin: 0 auto; }
.category-title { font-size: 24px; font-weight: 900; margin: 20px 6px 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
@media (min-width: 900px) { .card-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; } }
.card {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 10px 12px;
  border: 0; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
  text-align: center;
  transition: transform .15s ease, opacity .2s;
}
.card:active { transform: scale(.97); }
.thumb { aspect-ratio: 1 / 1; border-radius: 18px; overflow: hidden; background: var(--lilac); }
.thumb-canvas { width: 100%; height: 100%; display: block; }
.thumb-ph {
  width: 100%; height: 100%; display: grid; place-items: center; font-size: 40px;
  background: linear-gradient(135deg, #F3E8FF, #FFE4EF);
}
.thumb-ph span { opacity: .55; }
.card-title { font-size: 17px; font-weight: 800; line-height: 1.2; min-height: 1.2em; }
.badge { position: absolute; pointer-events: none; }
.free-badge {
  top: 16px; left: 16px; padding: 4px 10px; border-radius: 999px;
  background: var(--sun); color: var(--ink); font-size: 14px; font-weight: 900; box-shadow: var(--shadow-sm);
}
.cloud-badge {
  display: none; top: 14px; right: 14px; width: 48px; height: 48px; place-items: center;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); font-size: 28px; line-height: 1;
}
.card.locked .thumb, .card.locked .card-title { opacity: .45; filter: saturate(.35); }
.card.locked .cloud-badge { display: grid; }
.card-loading { display: none; }
.card.loading .card-loading {
  display: grid; place-items: center; position: absolute; inset: 0; font-size: 44px;
  border-radius: var(--radius); background: rgba(255, 255, 255, .55);
}
.card.loading .card-loading { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); opacity: .7; } }

/* ---------- paint ---------- */
.paint-screen { padding: 8px 12px 0; gap: 8px; }
.paint-top { flex: none; display: flex; align-items: center; gap: 8px; }
.paint-title {
  flex: 1; min-width: 0; text-align: center; font-size: 20px; font-weight: 900;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.done-btn {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 0 22px 0 18px;
  border: 0; border-radius: 999px;
  background: var(--pink); color: #fff;
  font-size: 20px; font-weight: 900; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(255, 111, 174, .45);
  transition: transform .15s;
}
.done-btn:active { transform: scale(.96); }
.done-btn svg { width: 26px; height: 26px; stroke-width: 6; }

.paint-main {
  flex: 1 1 auto; min-height: 0;
  display: grid; gap: 10px;
  grid-template-areas: "canvas" "tools" "palette";
  grid-template-rows: minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
}
.canvas-wrap { grid-area: canvas; position: relative; min-width: 0; min-height: 0; }
.canvas-stack {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border-radius: 20px; overflow: hidden; background: #fff;
  box-shadow: 0 10px 30px rgba(61, 44, 90, .18);
  touch-action: none; cursor: crosshair;
}
.tool-stickers .canvas-stack { cursor: copy; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.mirror-guide {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 0;
  border-left: 3px dashed rgba(139, 92, 246, .35); transform: translateX(-1.5px); pointer-events: none;
}

.tools-panel {
  grid-area: tools; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px;
}
.tool-list {
  flex: 0 1 auto; min-width: 0; max-width: 100%;
  display: flex; gap: 8px; padding: 6px;
  overflow-x: auto; scrollbar-width: none;
}
.tool-list::-webkit-scrollbar { display: none; }
.tool-btn {
  position: relative; flex: none;
  width: 64px; height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; border-radius: 20px; background: var(--card); box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tool-icon { font-size: 28px; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.tool-icon svg { width: 32px; height: 32px; }
.tool-btn.restart .tool-icon svg { width: 28px; height: 28px; color: var(--ink); }
.tool-label { font-size: 11px; font-weight: 800; line-height: 1; }
.tool-btn.selected, .swatch.selected, .size-btn.selected {
  box-shadow: 0 0 0 4px var(--violet), var(--shadow-sm);
  transform: scale(1.1);
}
.lock-badge {
  display: none; position: absolute; top: -6px; right: -6px; z-index: 1;
  padding: 2px 4px; border-radius: 999px; background: #fff; box-shadow: var(--shadow-sm);
  font-size: 11px; line-height: 1.1; pointer-events: none;
}
.locked > .lock-badge { display: block; }
.tool-btn.locked .tool-icon { opacity: .6; }

.tool-slot { flex: none; min-width: 196px; min-height: 64px; display: flex; align-items: center; justify-content: center; }
.sizes { flex: none; display: flex; gap: 10px; padding: 4px; }
.tool-hint {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px; min-height: 48px; padding: 0 16px;
  border: 0; border-radius: 999px; background: rgba(255, 255, 255, .6); color: var(--ink);
  font-size: 15px; font-weight: 800; line-height: 1.15; text-align: left; cursor: default;
}
.tool-hint.clickable { cursor: pointer; background: #fff; box-shadow: var(--shadow-sm); min-height: var(--tap); }
.tool-hint .emo { font-size: 26px; }
.size-btn {
  width: var(--tap); height: var(--tap); border: 0; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow-sm); display: grid; place-items: center;
  transition: transform .15s ease, box-shadow .15s ease;
}
.size-dot { width: var(--d); height: var(--d); border-radius: 50%; background: var(--current); box-shadow: inset 0 0 0 2px rgba(61, 44, 90, .18); }

.palette-panel { grid-area: palette; min-width: 0; padding: 0 2px 6px; }
.palette {
  display: grid; gap: 7px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  max-width: 560px; margin: 0 auto;
}
@media (min-width: 600px) and (orientation: portrait) {
  .palette { grid-template-columns: repeat(11, minmax(0, 1fr)); max-width: 820px; }
}
.swatch {
  position: relative; min-width: 0; aspect-ratio: 1 / 1; padding: 0;
  border: 3px solid #fff; border-radius: 50%;
  background: var(--c);
  box-shadow: 0 2px 7px rgba(61, 44, 90, .2);
  transition: transform .15s ease, box-shadow .15s ease;
}
.swatch[data-color="#FFFFFF"] { border-color: #E6DDF3; }
.swatch.rainbow { background: conic-gradient(#FF4D6D, #FF9F1C, #FFD23F, #8AC926, #4D96FF, #B983FF, #FF4D6D); }
.swatch.rainbow.locked { filter: saturate(.55); }

/* landscape tablets / desktop / Chromebook: tools left, palette right */
@media (orientation: landscape) and (min-width: 700px) {
  .paint-main {
    grid-template-areas: "tools canvas palette";
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
  }
  .tools-panel { flex-direction: column; flex-wrap: nowrap; justify-content: center; gap: 14px; }
  .tool-list { display: grid; grid-template-columns: repeat(3, 64px); gap: 10px; overflow: visible; padding: 6px; }
  .sizes { justify-content: center; }
  .palette-panel { display: flex; align-items: center; padding: 0 4px; }
  .palette { --sw: clamp(40px, calc((100dvh - 280px) / 8), 60px); grid-template-columns: repeat(3, var(--sw)); gap: 9px; }
}
/* short landscape screens (phones turned sideways) */
@media (orientation: landscape) and (min-width: 700px) and (max-height: 560px) {
  .paint-top .paint-title { display: none; }
  .tool-list { grid-template-columns: repeat(4, 52px); gap: 6px; }
  .tool-btn { width: 52px; height: 52px; border-radius: 16px; }
  .tool-label { display: none; }
  .sizes { gap: 6px; }
  .size-btn { width: 48px; height: 48px; }
  .palette { --sw: 38px; grid-template-columns: repeat(5, var(--sw)); gap: 6px; }
}
@media (max-width: 520px) {
  .home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .home-actions .pill { font-size: 16px; padding: 0 12px; gap: 8px; }
  .home-actions .pill:last-child { grid-column: 1 / -1; justify-self: center; padding: 0 28px; }
  .card-grid { gap: 12px; }
}
@media (max-width: 380px) {
  .done-btn { padding: 0 16px 0 12px; font-size: 18px; }
  .paint-title { font-size: 16px; }
}

/* ---------- gallery ---------- */
.screen-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.screen-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 30px; font-weight: 900; }
.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; width: 100%; max-width: 1200px; margin: 0 auto; }
.art-card { aspect-ratio: 1 / 1; padding: 8px; border: 0; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.art-card img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }
.empty { grid-column: 1 / -1; text-align: center; padding: 48px 16px; font-size: 24px; }
.empty-emoji { font-size: 72px; }
.empty-sub { font-size: 18px; opacity: .75; }
.viewer-img { display: block; width: 100%; max-width: 480px; height: auto; margin: 8px auto 0; border-radius: 20px; box-shadow: var(--shadow); }
.viewer-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }

/* ---------- sheets / overlays ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(61, 44, 90, .35);
  opacity: 0; transition: opacity .18s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet-backdrop.closing { opacity: 0; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 90vh; max-height: 90dvh; overflow: auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0; background: var(--card);
  box-shadow: 0 -10px 40px rgba(61, 44, 90, .2);
  text-align: center;
  transform: translateY(40px); transition: transform .2s ease;
}
.open .sheet { transform: none; }
@media (min-width: 640px) and (min-height: 560px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 28px; padding-bottom: 28px; }
}
.sheet.viewer { max-width: 640px; }
.sheet-x { position: absolute; top: 12px; right: 12px; background: var(--lilac); box-shadow: none; }
.sheet-x svg { width: 24px; height: 24px; }
.sheet-emoji { font-size: 48px; line-height: 1.2; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.sheet-title { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 52px 12px; font-size: 26px; font-weight: 900; line-height: 1.2; }
.sheet-sub { margin: 18px 0 10px; font-size: 20px; font-weight: 900; }
.sheet-text { font-size: 19px; line-height: 1.4; margin: 0 8px 12px; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 12px; }
.sheet-actions.column { flex-direction: column; align-items: stretch; }
.fine { margin: -4px 8px 4px; font-size: 14px; opacity: .7; font-weight: 600; }
.owned { padding: 16px; border-radius: 22px; background: #E3FAF7; font-size: 17px; }
.about { margin-top: 20px; padding: 14px 16px; border-radius: 20px; background: var(--lilac); text-align: left; }
.about h3 { margin: 0 0 6px; font-size: 17px; }
.about p { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.45; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--tap); padding: 0 8px 0 20px; border-radius: 999px; background: var(--lilac); font-size: 18px;
}
.setting-row > span { display: inline-flex; align-items: center; gap: 10px; }
.switch { position: relative; width: 84px; height: 48px; border: 0; border-radius: 999px; background: #CFC6DD; transition: background .2s; }
.switch[aria-checked="true"] { background: var(--mint); }
.knob { position: absolute; top: 4px; left: 4px; width: 40px; height: 40px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch[aria-checked="true"] .knob { transform: translateX(36px); }

/* parental gate */
.gate-q { font-size: 23px; margin: 4px 0 18px; }
.gate-answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; max-width: 380px; margin: 0 auto; }
.gate-btn { min-height: 76px; border: 0; border-radius: 22px; background: var(--lilac); font-size: 32px; font-weight: 900; transition: transform .12s; }
.gate-btn:active { transform: scale(.95); }

/* big ✓ / ✗ */
.sheet.compact { max-width: 420px; }
.yesno { display: flex; justify-content: center; gap: 28px; margin: 10px 0 4px; }
.big-round { width: 92px; height: 92px; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; box-shadow: var(--shadow); transition: transform .12s; }
.big-round svg { width: 46px; height: 46px; stroke-width: 6; }
.big-round.yes { background: var(--mint); }
.big-round.no { background: var(--pink); }
.big-round:active { transform: scale(.94); }

/* stickers */
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; }
.sticker-btn {
  position: relative; aspect-ratio: 1 / 1; min-height: 64px; border: 0; border-radius: 20px; background: var(--lilac);
  font-size: 38px; line-height: 1; transition: transform .15s, box-shadow .15s;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.sticker-btn.selected { box-shadow: 0 0 0 4px var(--violet); transform: scale(1.06); }
.sticker-btn.locked .sticker-emoji { opacity: .45; }

/* sparkle pack */
.sparkle-preview { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 8px; }
.sparkle-preview span { padding: 8px 14px; border-radius: 999px; background: var(--lilac); font-size: 16px; }
.pill.watch { min-height: 64px; }
.pill.watch .icon svg { width: 26px; height: 26px; }
.btn-stack { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.btn-note { font-size: 13px; font-weight: 700; opacity: .85; }
.btn-note:empty { display: none; }

/* celebration */
.sheet-backdrop:has(.celebrate) { align-items: center; padding: 16px; }
.sheet.celebrate { border-radius: 28px; max-width: 460px; overflow: visible; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.celebrate-stars { font-size: 30px; letter-spacing: 6px; }
.celebrate-title { margin: 4px 0 12px; font-size: 46px; font-weight: 900; color: var(--pink); }
.celebrate-art { display: block; width: min(220px, 50vw); height: auto; margin: 0 auto 18px; border-radius: 22px; box-shadow: var(--shadow); }
.celebrate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--ad-h) + 28px); z-index: 2000;
  max-width: calc(100vw - 32px); padding: 14px 22px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 18px; text-align: center;
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* sparkle burst */
.burst { position: fixed; left: 50%; top: 50%; z-index: 3000; pointer-events: none; }
.burst span { position: absolute; left: 0; top: 0; font-size: 34px; animation: burst 1.1s ease-out forwards; }
@keyframes burst {
  from { transform: translate(-50%, -50%) scale(.3); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
