:root{
  --purple:#7C5CD6;--purple2:#9B7BEF;--purple-deep:#5E3EBE;--purple-soft:#EFEAFB;
  --accent:#FFCE5C;--text:#3B2E6B;--muted:#8A82A6;--danger:#F0554F;
  --card-border:#ECE6FA;--shadow:0 10px 30px rgba(108,84,196,0.10);
}
*{box-sizing:border-box;margin:0;padding:0}
/* Guard: no horizontal overflow/scroll (the scroll can live on <html>, so clip
   both). `clip` keeps the sticky header working, unlike `hidden`. */
html{overflow-x:hidden;overflow-x:clip}
body{font-family:'Assistant',system-ui,sans-serif;color:var(--text);
  background:linear-gradient(180deg,#F5F1FF 0%,#FBF9FF 45%,#F6F1FF 100%);
  background-attachment:fixed;min-height:100vh;direction:rtl;-webkit-font-smoothing:antialiased;
  overflow-x:hidden;overflow-x:clip}
/* Media never forces the page wider than the screen. */
img,svg,video,canvas{max-width:100%}
.hidden{display:none !important}
.card{background:#fff;border:1px solid var(--card-border);border-radius:26px;box-shadow:var(--shadow);padding:24px}
.card-title{font-size:20px;font-weight:800;text-align:center;margin-bottom:18px;display:flex;align-items:center;justify-content:center;gap:8px}
.card-title .ti{color:var(--purple2)}
.muted{color:var(--muted)}
.wrap{max-width:1240px;margin:0 auto;padding:28px 24px}

/* Full-width header */
header{background:rgba(255,255,255,0.92);backdrop-filter:blur(8px);border-bottom:1px solid var(--card-border);
  box-shadow:0 4px 20px rgba(108,84,196,0.07);position:sticky;top:0;z-index:50}
.header-inner{display:flex;align-items:center;justify-content:space-between;height:78px;max-width:1240px;margin:0 auto;padding:0 24px;width:100%}
.header-side{display:flex;align-items:center;gap:14px;flex:1}
.header-profile{justify-content:flex-start}
.header-home{justify-content:flex-end}
.home-btn{display:flex;align-items:center;gap:8px;background:var(--purple-soft);border:1px solid var(--card-border);
  padding:10px 18px;border-radius:16px;font-weight:700;color:var(--purple);cursor:pointer;font-size:15px}
.brand{display:flex;flex-direction:column;align-items:center;line-height:1.1;flex:0 0 auto;cursor:pointer;transition:transform .12s}
.brand:hover{transform:scale(1.04)}
.brand:focus-visible{outline:2px solid var(--purple);outline-offset:4px;border-radius:10px}
.brand-title{font-size:27px;font-weight:800;color:var(--purple);display:flex;align-items:center;gap:8px}
.brand-title .ti{color:var(--accent);font-size:24px}
.brand-logo{width:38px;height:38px;object-fit:contain;flex:none;filter:drop-shadow(0 3px 6px rgba(108,84,196,0.22))}
/* Unicorn mascot images keep their aspect ratio inside the sized boxes */
.empty-mascot,.welcome-mascot,.lo-mascot,.mascot{object-fit:contain}
.brand-sub{font-size:13px;color:var(--muted);font-weight:600;margin-top:2px}
.h-avatar{width:44px;height:44px;border-radius:50%;background:#D8E9FF;display:flex;align-items:center;justify-content:center;color:#4B86D8;font-size:24px;overflow:hidden;flex:none}
.h-avatar img{width:100%;height:100%;object-fit:cover}
.user-meta a{cursor:pointer}
.google-btn-host{display:flex;align-items:center;min-height:44px}
.user-meta{display:flex;flex-direction:column;line-height:1.2;text-align:right}
.user-meta b{font-size:14px}
.user-meta a{font-size:13px;color:var(--purple);text-decoration:none;font-weight:700}
.gear{width:42px;height:42px;border-radius:14px;border:1px solid var(--card-border);background:#fff;display:flex;align-items:center;justify-content:center;color:var(--muted);cursor:pointer;font-size:20px}

/* Dev-only mock toggle (localhost) */
.mock-toggle{display:flex;align-items:center;gap:8px;cursor:pointer;user-select:none;padding:6px 12px;border-radius:16px;border:1px solid var(--card-border);background:#fff}
.mock-toggle input{position:absolute;opacity:0;width:0;height:0}
.mock-switch{position:relative;width:38px;height:22px;border-radius:999px;background:#D8D0EC;transition:background .15s;flex:none}
.mock-switch::after{content:"";position:absolute;top:2px;right:2px;width:18px;height:18px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.2);transition:transform .15s}
.mock-toggle input:checked + .mock-switch{background:var(--purple)}
.mock-toggle input:checked + .mock-switch::after{transform:translateX(-16px)}
.mock-toggle-label{font-size:13.5px;font-weight:700;color:var(--purple-deep);display:flex;align-items:center;gap:5px}
.mock-toggle-label .ti{color:var(--accent);font-size:16px}

/* Layout */
.grid{display:grid;grid-template-columns:330px minmax(400px,1fr) 330px;gap:24px;align-items:start}
.grid2{display:grid;grid-template-columns:360px minmax(0,1fr);gap:24px;align-items:start;margin-bottom:24px}
.col{display:flex;flex-direction:column;gap:24px}

/* Full-width login banner */
.login-card{display:flex;align-items:center;justify-content:space-between;gap:28px;flex-wrap:wrap;margin-bottom:24px}
.login-text{flex:1;min-width:260px}
.login-h{font-size:19px;font-weight:800;color:var(--text);display:flex;align-items:center;gap:8px;margin-bottom:6px}
.login-h .ti{color:var(--purple2)}
.login-text p{font-size:14px;line-height:1.6}
.login-actions{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.login-actions .google-btn,.login-actions .ghost-btn{width:auto;margin:0;padding:0 22px;height:50px}
.or-inline{color:var(--muted);font-size:13px;font-weight:700}

/* Form */
.step{margin-bottom:20px}
/* Optional step that fades in once the user starts filling the form. */
.step-reveal:not(.hidden){animation:step-in .35s ease}
@keyframes step-in{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:none}}
.step-head{display:flex;align-items:flex-start;gap:11px;margin-bottom:10px}
.badge{width:34px;height:34px;border-radius:50%;flex:none;background:var(--purple);
  color:#fff;font-weight:800;display:flex;align-items:center;justify-content:center;font-size:16px;margin-top:1px}
.step-title{font-weight:700;font-size:15px;line-height:1.35;color:var(--purple-deep)}
.optional{font-size:12.5px;color:var(--muted);font-weight:600;margin-top:2px}
.field-wrap{position:relative}
input.field,textarea.field{width:100%;border:1.5px solid var(--card-border);border-radius:16px;padding:13px 15px;
  font-family:inherit;font-size:15px;color:var(--text);background:#FBFAFF;resize:none}
input.field:focus,textarea.field:focus{outline:none;border-color:var(--purple2);background:#fff}
.field-star{position:absolute;top:-8px;left:12px;color:var(--accent);font-size:20px}

/* --- scenery picker ------------------------------------------------------- */
/* Room for the picker button on the physical left of the environment field. */
.env-field input.field{padding-left:48px}
.scene-btn{position:absolute;top:50%;left:7px;transform:translateY(-50%);z-index:2;
  width:34px;height:34px;border:none;border-radius:12px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  background:var(--purple-soft);color:var(--purple);font-size:19px;
  transition:background .15s ease,color .15s ease,transform .15s ease}
.scene-btn:hover{background:var(--purple);color:#fff}
.scene-btn:active{transform:translateY(-50%) scale(.94)}
.scene-btn[aria-expanded="true"]{background:var(--purple);color:#fff}

.scene-pop{position:absolute;top:calc(100% + 8px);left:0;z-index:30;width:min(340px,86vw);
  background:#fff;border:1.5px solid var(--card-border);border-radius:18px;
  box-shadow:var(--shadow);padding:14px;animation:step-in .18s ease}
.scene-pop-title{font-weight:700;font-size:14px;color:var(--purple-deep);margin-bottom:10px}
.scene-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px 8px}
@media (max-width:420px){.scene-grid{grid-template-columns:repeat(3,1fr)}}
.scene-tile{border:none;background:none;padding:0;cursor:pointer;display:flex;
  flex-direction:column;align-items:center;gap:5px;font-family:inherit}
.scene-thumb{width:100%;aspect-ratio:1/1;border-radius:13px;object-fit:cover;
  border:2px solid transparent;background:var(--purple-soft);
  transition:border-color .15s ease,transform .15s ease}
.scene-tile:hover .scene-thumb{border-color:var(--purple2);transform:translateY(-2px)}
.scene-tile:active .scene-thumb{transform:scale(.95)}
.scene-label{font-size:12px;font-weight:600;color:var(--text);line-height:1.2;text-align:center}
.create-btn{width:100%;height:58px;border:none;border-radius:18px;margin-top:8px;background:var(--purple);
  color:#fff;font-weight:800;font-size:19px;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;
  box-shadow:0 10px 22px rgba(124,92,214,0.35);transition:filter .15s}
.create-btn:hover{filter:brightness(1.05)}
.create-btn:disabled{opacity:.7;cursor:default}
.create-btn .ti{color:var(--accent)}
.create-hint{text-align:center;font-size:12.5px;color:var(--muted);margin-top:10px}
/* Prominent, hard-to-miss failure banner shown above the create button. */
.create-error{display:flex;align-items:flex-start;gap:10px;margin-top:12px;padding:14px 16px;
  background:#FDECEB;border:2px solid var(--danger);border-radius:16px;color:#B23A34;
  font-size:15.5px;font-weight:700;line-height:1.5;text-align:right;
  box-shadow:0 8px 20px rgba(240,85,79,0.18);animation:errPop .28s ease}
.create-error .ti{color:var(--danger);font-size:22px;flex:none;margin-top:1px}
@keyframes errPop{0%{opacity:0;transform:translateY(-6px)}60%{transform:translateY(2px)}100%{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){.create-error{animation:none}}

/* Empty canvas */
.empty-canvas{position:relative;border-radius:22px;aspect-ratio:1/1;border:2.5px dashed #D9CEF7;
  background:linear-gradient(180deg,#FBF9FF,#F3EEFF);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:24px;text-align:center}
.empty-mascot{width:120px;height:120px}
.empty-h{font-size:21px;font-weight:800;color:var(--purple-deep)}
.empty-p{font-size:14.5px;color:var(--muted);line-height:1.7;max-width:320px}
.empty-badge{position:absolute;top:16px;left:16px;width:44px;height:44px;border-radius:50%;background:#fff;border:1px solid var(--card-border);
  display:flex;align-items:center;justify-content:center;color:#D0C6EC;font-size:22px}
.float-star{position:absolute;color:var(--accent);font-size:22px;opacity:.9}

/* Loading */
.loading-canvas{border-radius:22px;aspect-ratio:1/1;background:linear-gradient(135deg,#F3EEFF,#FBF9FF);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:20px;text-align:center}
.spinner{width:64px;height:64px;border-radius:50%;border:6px solid #E7DEFB;border-top-color:var(--purple);animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.loading-h{font-size:19px;font-weight:800;color:var(--purple-deep)}
.loading-p{font-size:14px;color:var(--muted)}

/* Compact actions panel (beside the image after creation) — two square
   tiles per row. .actions.actions-compact out-specifies the base .actions
   (repeat(3,1fr)) rule that appears later in this file. */
.actions.actions-compact{grid-template-columns:1fr 1fr;gap:14px}
.actions-compact .action{aspect-ratio:1/1;padding:12px 10px;gap:6px;justify-content:center}
.actions-compact .a-icon{font-size:32px;height:38px}
.actions-compact .a-title{font-size:14px}
.actions-compact .a-sub{font-size:11.5px}

/* On-request feature generation (story / comic / coloring) */
.gen-cta{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:12px;padding:14px 10px 6px;min-height:210px}
.gen-illo{width:64px;height:64px;border-radius:18px;display:flex;align-items:center;justify-content:center;font-size:32px}
.gen-cta p{font-size:14px;color:var(--muted);line-height:1.6;max-width:340px}
.gen-btn{background:var(--purple);color:#fff;border:none;border-radius:14px;padding:12px 24px;font-weight:800;font-size:15px;
  cursor:pointer;display:inline-flex;align-items:center;gap:8px;box-shadow:0 8px 18px rgba(124,92,214,0.30);transition:filter .15s}
.gen-btn:hover{filter:brightness(1.05)}
.gen-error{font-size:13px;color:var(--danger);line-height:1.5;max-width:340px}
.gen-btn .ti{color:var(--accent)}
.gen-loading{display:flex;flex-direction:column;align-items:center;gap:14px;padding:26px 10px}
.gen-loading .spinner{width:44px;height:44px;border-width:5px}
.gen-loading p{font-size:13.5px;color:var(--muted)}

/* Joke feature */
.joke-bubble{position:relative;background:#FFF9EC;border:1.5px solid #F6E4BE;border-radius:20px;padding:20px 22px;text-align:center}
.joke-quote{color:#E4972A;font-size:22px}
.joke-text{font-size:16.5px;line-height:1.85;color:var(--text);font-weight:600;margin-top:6px}
.joke-replay{margin:16px auto 0}
.secret-bubble{position:relative;background:#F3EEFF;border:1.5px solid #E0D5F7;border-radius:20px;padding:20px 22px;text-align:center}
.secret-quote{color:var(--purple2);font-size:22px}
.secret-text{font-size:16.5px;line-height:1.85;color:var(--text);font-weight:600;margin-top:6px}
.secret-replay{margin:16px auto 0}

/* Inspiration */
.chips{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:6px}
.idea-chip{border:1.5px solid var(--card-border);background:#FBFAFF;border-radius:16px;padding:11px 16px;
  font-weight:700;font-size:14px;color:var(--purple-deep);cursor:pointer;display:flex;align-items:center;gap:8px;transition:.15s}
.idea-chip:hover{border-color:var(--purple2);background:#fff;transform:translateY(-2px)}
.idea-chip .ti{color:var(--purple2);font-size:18px}

/* Main image (created) */
/* Ambient "bleed": a blurred, stretched copy of the current image sits behind
   the picture and fades into the card, so the white side gaps on a shared view
   pick up colors sampled from the image itself instead of a hard white edge.
   .img-stage hugs the image (see the shared-view cap below) so the bleed layer
   anchors to the picture's edges. */
.img-stage{position:relative}
.img-bleed{display:none;position:absolute;inset:0;z-index:0;
  background-repeat:no-repeat;background-position:center;background-size:100% 100%;
  filter:blur(52px) saturate(1.12);opacity:1;pointer-events:none;
  -webkit-mask-image:radial-gradient(125% 100% at 50% 50%,#000 42%,rgba(0,0,0,.6) 66%,transparent 88%);
          mask-image:radial-gradient(125% 100% at 50% 50%,#000 42%,rgba(0,0,0,.6) 66%,transparent 88%)}
body.shared-view .img-bleed{display:block}
.img-stage .main-img-wrap{z-index:1}
.main-img-wrap{position:relative;border-radius:22px;overflow:hidden;aspect-ratio:1/1;background:#F3EEFF;display:flex;align-items:center;justify-content:center}
.main-img-wrap img{width:100%;height:100%;object-fit:cover;display:block}
.fav-btn{position:absolute;top:16px;left:16px;width:46px;height:46px;border-radius:50%;background:rgba(255,255,255,0.92);
  border:none;display:flex;align-items:center;justify-content:center;color:var(--danger);font-size:22px;cursor:pointer;box-shadow:var(--shadow)}
.fav-btn.active{background:var(--danger);color:#fff}
.share-btn{position:absolute;top:16px;right:16px;width:46px;height:46px;border-radius:50%;background:rgba(255,255,255,0.92);
  border:none;display:flex;align-items:center;justify-content:center;color:var(--purple);font-size:22px;cursor:pointer;box-shadow:var(--shadow)}
.prompt-chip{position:absolute;bottom:14px;right:14px;left:14px;background:rgba(46,34,92,0.72);color:#fff;padding:10px 16px;border-radius:14px;font-size:14px;font-weight:600;backdrop-filter:blur(4px)}
.creature-name-row{display:flex;align-items:center;justify-content:center;gap:8px;margin-top:16px;min-height:38px}
/* When the name row serves as the card header (in place of the old title) */
.creature-name-row.as-title{margin-top:0;margin-bottom:18px}
.creature-name-row.as-title .creature-name-text{font-size:24px}
.creature-name-text{font-size:22px;font-weight:800;color:var(--text);text-align:center}
.name-edit-btn{flex:none;width:34px;height:34px;border-radius:12px;border:1.5px solid var(--card-border);background:#FBFAFF;color:var(--muted);display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:18px}
.name-edit-btn:hover{color:var(--text);border-color:var(--purple2)}
.creature-name-input{width:100%;max-width:320px;border:1.5px solid var(--purple2);border-radius:16px;padding:9px 14px;font-family:inherit;font-size:20px;font-weight:800;text-align:center;color:var(--text);background:#fff}
.creature-name-input:focus{outline:none}
.cta-row{display:flex;align-items:center;gap:10px;margin-top:18px}
.cta-arrow{flex:none;color:#C4B4F0}
.cta-arrow.flip{transform:scaleX(-1)}
.img-actions{flex:1;display:grid;grid-template-columns:1fr 1fr;gap:14px}
.btn{height:52px;border-radius:16px;font-weight:800;font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;border:none}
.btn-outline{background:#fff;border:1.5px solid var(--card-border);color:var(--purple)}
.btn-yellow{background:var(--accent);color:#7A5A00}
.signin-note{font-size:13px;color:var(--muted);text-align:center;margin-top:14px}

/* Account */
.google-btn{width:100%;height:52px;border-radius:16px;border:1.5px solid var(--card-border);background:#fff;
  display:flex;align-items:center;justify-content:center;gap:10px;font-weight:800;font-size:15px;color:var(--text);cursor:pointer;margin-bottom:12px}
.gicon{width:20px;height:20px}
.or-sep{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:13px;margin:12px 0}
.or-sep::before,.or-sep::after{content:"";flex:1;height:1px;background:var(--card-border)}
.ghost-btn{width:100%;height:48px;border-radius:16px;border:1.5px solid var(--card-border);background:#FBFAFF;
  display:flex;align-items:center;justify-content:center;gap:8px;font-weight:700;color:var(--muted);cursor:pointer}

/* Gallery */
.gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:14px}
.g-thumb{width:100%;aspect-ratio:1/1;border-radius:16px;display:flex;align-items:center;justify-content:center;font-size:40px;color:#fff;overflow:hidden}
.g-thumb img{width:100%;height:100%;object-fit:cover}
.g-label{font-size:13px;font-weight:700;text-align:center;margin-top:7px}
.gallery-more{display:block;margin:16px auto 0;background:var(--purple-soft);color:var(--purple);border:1px solid var(--card-border);padding:10px 24px;border-radius:14px;font-weight:800;font-size:14px;cursor:pointer;transition:background .15s}
.gallery-more:hover{background:#E7DEFB}
.g-foot{display:block;text-align:center;margin-top:16px;color:var(--purple);font-weight:800;font-size:14px;text-decoration:none;cursor:pointer}
[data-portfolio]{cursor:pointer}
[data-portfolio] .g-thumb{transition:transform .15s}
[data-portfolio]:hover .g-thumb{transform:translateY(-3px)}
[data-portfolio].g-active .g-thumb{outline:3px solid var(--purple);outline-offset:2px}
.gallery-empty{display:flex;flex-direction:column;align-items:center;text-align:center;gap:10px;padding:18px 8px 6px}
.gallery-empty .slots{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:12px;width:100%;margin-bottom:6px}
.slot{aspect-ratio:1/1;border-radius:16px;border:2px dashed #E0D8F5;background:#FBFAFF;display:flex;align-items:center;justify-content:center;color:#D0C6EC;font-size:28px}
.gallery-empty p{font-size:13.5px;color:var(--muted);line-height:1.6}

/* Lower two-column */
.lower{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px;align-items:start;margin-top:24px}
.section-sub{text-align:center;font-size:13px;color:var(--muted);margin:-10px 0 16px}

/* Unlock note + lock tags */
.unlock-note{margin-top:24px;display:flex;align-items:center;justify-content:center;gap:10px;
  background:#fff;border:1.5px dashed #D9CEF7;border-radius:20px;padding:16px 24px;color:var(--purple-deep);font-weight:700;font-size:15px;box-shadow:var(--shadow)}
.unlock-note .ti{color:var(--purple2);font-size:22px}
.lock-tag{display:flex;align-items:center;justify-content:center;gap:6px;background:var(--purple-soft);color:var(--purple);
  font-weight:700;font-size:12.5px;padding:6px 12px;border-radius:12px;margin:-8px auto 16px;width:fit-content}
.lock-tag .ti{font-size:16px}
.locked-body{opacity:.5;pointer-events:none}
/* "דוגמה" tag on starter (example) creations — so first-time users know these
   are demos, not their own (or someone else's) work. */
.example-badge{position:absolute;top:8px;right:8px;z-index:3;display:inline-flex;align-items:center;gap:4px;
  background:var(--accent);color:#7A5A00;font-size:11px;font-weight:800;padding:3px 9px;border-radius:999px;
  box-shadow:0 3px 8px rgba(0,0,0,.18);pointer-events:none;white-space:nowrap}
.example-badge .ti{font-size:13px}
/* "בענן" / "מקומי" status tag. Inline by default (used in the name row); on a
   thumbnail it sits in the top-left corner (example badge takes the top-right). */
.sync-badge{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:800;
  padding:3px 9px;border-radius:999px;white-space:nowrap}
.sync-badge .ti{font-size:13px}
.sync-badge.synced{background:#E3F5EA;color:#1E8E5A}
.sync-badge.local{background:#EFECF6;color:#8A82A6}
.g-thumb .sync-badge,.wc-thumb .sync-badge{position:absolute;top:8px;left:8px;z-index:3;box-shadow:0 3px 8px rgba(0,0,0,.15)}
.g-thumb,.wc-thumb{position:relative}
/* On the big creature image, center it along the top (corners hold fav/share). */
.main-img-wrap .example-badge{top:16px;left:50%;right:auto;transform:translateX(-50%);font-size:13px;padding:5px 14px}

/* Versions */
.versions{display:flex;gap:14px;justify-content:center;overflow-x:auto;padding-bottom:4px}
/* Versions shown as a small filmstrip under the main image, in the same card */
.versions-inline{margin-top:18px;padding-top:16px;border-top:1px solid var(--card-border);gap:12px}
.versions-inline .ver{width:82px}
.versions-inline .ver-thumb{width:82px;height:82px}
.ver{flex:none;width:96px;cursor:pointer}
.ver-thumb{width:96px;height:96px;border-radius:16px;border:3px solid transparent;overflow:hidden;background:#F3EEFF;display:flex;align-items:center;justify-content:center;font-size:36px;color:#fff}
.ver-thumb img{width:100%;height:100%;object-fit:cover}
.ver.selected .ver-thumb{border-color:var(--purple)}
.ver-label{font-size:12px;text-align:center;margin-top:7px;font-weight:700;color:var(--muted)}
.ver.selected .ver-label{color:var(--purple)}
.ver-add .ver-thumb{background:var(--purple-soft);color:var(--purple);border:3px dashed #D9CEF7}
.ph-thumb{width:88px;height:88px;border-radius:16px;border:2px dashed #E0D8F5;background:#FBFAFF;display:flex;align-items:center;justify-content:center;color:#CFC6EA;font-size:28px}

/* Story */
.story-row{display:flex;gap:18px;align-items:center}
.story-body{flex:1}
.story-text{font-size:14.5px;line-height:1.9;color:#5A5178}
.story-thumb{width:150px;height:150px;flex:none;border-radius:18px;overflow:hidden;background:#F3EEFF;display:flex;align-items:center;justify-content:center;font-size:60px;color:#fff}
.story-thumb img{width:100%;height:100%;object-fit:cover}
.read-btn{margin-top:14px;background:var(--purple);color:#fff;border:none;padding:10px 18px;border-radius:14px;font-weight:700;font-size:14px;cursor:pointer;display:inline-flex;align-items:center;gap:8px}
.ph-line{height:13px;border-radius:7px;background:#EFEAFB;margin-bottom:11px}
.ph-story-thumb{width:150px;height:150px;flex:none;border-radius:18px;border:2px dashed #E0D8F5;background:#FBFAFF;display:flex;align-items:center;justify-content:center;color:#CFC6EA;font-size:52px}

/* Storybook cover (inline) — looks like a closed book you can open */
.storybook{display:flex;justify-content:center;padding:4px 0}
.storybook-cover{position:relative;display:flex;width:100%;max-width:440px;cursor:pointer;border-radius:16px;overflow:hidden;
  background:linear-gradient(135deg,#7C5CD6,#9B7BEF);box-shadow:0 14px 30px rgba(108,84,196,.30);transition:transform .18s,box-shadow .18s}
.storybook-cover:hover{transform:translateY(-3px) scale(1.012);box-shadow:0 22px 44px rgba(108,84,196,.4)}
.storybook-cover::after{content:"";position:absolute;top:0;bottom:0;right:0;width:16px;background:linear-gradient(90deg,rgba(255,255,255,.28),rgba(255,255,255,0));pointer-events:none} /* spine highlight on the RTL binding side */
.storybook-art{width:138px;height:158px;flex:none;overflow:hidden;background:#F3EEFF}
.storybook-art img{width:100%;height:100%;object-fit:cover}
.storybook-meta{flex:1;display:flex;flex-direction:column;justify-content:center;gap:9px;padding:18px 20px;color:#fff}
.storybook-label{font-size:12.5px;font-weight:700;opacity:.88;display:flex;align-items:center;gap:6px}
.storybook-title{font-size:20px;font-weight:800;line-height:1.25}
.storybook-open{align-self:flex-start;margin-top:2px;background:rgba(255,255,255,.2);border:1px solid rgba(255,255,255,.4);
  padding:7px 14px;border-radius:12px;font-size:13px;font-weight:700;display:inline-flex;align-items:center;gap:6px}

/* Once a story exists, the book cover takes over the whole card instead of
   sitting as a smaller tile inside it — no card-in-card. Scoped via :has() to
   the story card (the only one holding a .storybook) so no JS hook is needed. */
.card:has(.gen-content:not(.hidden) .storybook){padding:0;border:none;background:transparent;box-shadow:none;overflow:visible}
.card:has(.gen-content:not(.hidden) .storybook) > .card-title{display:none}
.card:has(.gen-content:not(.hidden) .storybook) .storybook{padding:0}
.card:has(.gen-content:not(.hidden) .storybook) .storybook-cover{max-width:none;width:100%;border-radius:26px;min-height:230px}
.card:has(.gen-content:not(.hidden) .storybook) .storybook-art{width:230px;height:auto}
.card:has(.gen-content:not(.hidden) .storybook) .storybook-meta{padding:22px 26px}
.card:has(.gen-content:not(.hidden) .storybook) .storybook-title{font-size:23px}

/* Storybook reader — an open two-page book */
.book-modal{position:fixed;inset:0;z-index:100;background:rgba(46,34,92,.74);backdrop-filter:blur(6px);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:20px;padding:24px;animation:bookFade .2s ease}
/* When opened from an "all-…" page (z-index 120), lift the reader above it. */
.book-modal.over-page{z-index:130}
@keyframes bookFade{from{opacity:0}to{opacity:1}}
.book-close{position:absolute;top:18px;left:18px;width:46px;height:46px;border-radius:50%;border:none;background:#fff;color:var(--text);
  font-size:22px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow)}
.book{position:relative;display:flex;width:min(880px,94vw);height:min(560px,72vh);border-radius:14px;background:#fff;
  box-shadow:0 34px 80px rgba(0,0,0,.45);perspective:2400px;animation:bookOpen .35s cubic-bezier(.2,.8,.3,1)}
@keyframes bookOpen{from{transform:scale(.9) rotateX(8deg);opacity:0}to{transform:none;opacity:1}}
.book-page{flex:1;position:relative;overflow:hidden}
.book-page-art{border-radius:0 14px 14px 0;background:linear-gradient(160deg,#FFF6E6,#FDE9F1);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;padding:28px}
.book-title{font-size:22px;font-weight:800;color:var(--purple-deep);text-align:center;line-height:1.3}
.book-illo{width:min(280px,64%);aspect-ratio:1;border-radius:20px;overflow:hidden;background:#fff;box-shadow:0 12px 28px rgba(0,0,0,.2)}
.book-illo img{width:100%;height:100%;object-fit:cover}
.book-page-text{border-radius:14px 0 0 14px;background:#FFFDF8;padding:34px 32px;display:flex;flex-direction:column;
  transform-origin:right center;transition:transform .32s ease;backface-visibility:hidden}
.book-page-text.turning{transform:rotateY(-108deg)}
.book-text{flex:1;overflow:auto;font-size:19px;line-height:2;color:#4A4270;text-align:right}
.book-text p{margin-bottom:15px}
.book-page-num{margin-top:14px;text-align:center;font-size:12.5px;color:var(--muted);font-weight:700}
.book-spine{position:absolute;left:calc(50% - 15px);top:0;bottom:0;width:30px;z-index:3;pointer-events:none;
  background:linear-gradient(90deg,rgba(0,0,0,0),rgba(0,0,0,.14),rgba(0,0,0,0))}
.book-nav{display:flex;align-items:center;gap:16px}
.book-nav-btn{width:52px;height:52px;border-radius:50%;border:none;background:#fff;color:var(--purple);font-size:24px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow);transition:transform .12s}
.book-nav-btn:hover:not(:disabled){transform:scale(1.08)}
.book-nav-btn:disabled{opacity:.4;cursor:default}
.book-read{background:var(--accent);color:#7A5A00;border:none;padding:13px 22px;border-radius:16px;font-weight:800;font-size:15px;
  cursor:pointer;display:inline-flex;align-items:center;gap:8px;box-shadow:0 8px 18px rgba(255,206,92,.5)}
@media(max-width:640px){
  .book-modal{padding:12px;gap:12px}
  .book{flex-direction:column;width:min(880px,96vw);height:min(88vh,820px)}
  /* Art page shrinks to fit its illustration instead of taking half the book,
     so the story text (below) gets the lion's share of the screen. */
  .book-page-art{flex:0 0 auto;border-radius:14px 14px 0 0;padding:14px;gap:10px}
  .book-illo{width:min(130px,34vw)}
  .book-title{font-size:19px}
  .book-page-text{flex:1 1 auto;border-radius:0 0 14px 14px;transform-origin:center top;padding:20px 20px 14px}
  .book-page-text.turning{transform:rotateX(108deg)}
  .book-spine{display:none}
  .book-nav-btn{width:46px;height:46px;font-size:22px}
}

/* Child */
.child-row{display:flex;gap:16px;align-items:stretch}
.child-preview{flex:1;border-radius:18px;background:linear-gradient(135deg,#D8E9FF,#FFE1C4);display:flex;align-items:center;justify-content:center;gap:6px;font-size:52px;color:#fff;min-height:170px}
.child-preview img{width:100%;height:100%;object-fit:cover;border-radius:18px}
.upload-box{flex:none;width:160px;border:2px dashed #D9CEF7;border-radius:18px;padding:20px 14px;text-align:center;background:#FBFAFF;display:flex;flex-direction:column;align-items:center;justify-content:center}
.upload-box .ti{font-size:34px;color:var(--purple)}
.upload-btn{margin-top:14px;width:100%;background:var(--purple);color:#fff;border:none;border-radius:12px;padding:10px;font-weight:700;font-size:12.5px;cursor:pointer}
.ph-child{flex:1;border-radius:18px;border:2px dashed #E0D8F5;background:#FBFAFF;display:flex;align-items:center;justify-content:center;color:#CFC6EA;font-size:48px;min-height:160px}

/* Actions */
.actions{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}
.action{border:1px solid var(--card-border);border-radius:20px;padding:20px 12px;background:#fff;cursor:pointer;
  transition:transform .15s,box-shadow .15s;display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px}
.action:hover{transform:translateY(-4px);box-shadow:var(--shadow)}
.a-icon{font-size:38px;line-height:1;height:44px;display:flex;align-items:center}
.a-title{font-weight:800;font-size:15px}
.a-sub{font-size:12.5px;color:var(--muted)}
.action.danger{border-color:#FAD4D3;background:#FEF6F6}
.plus-circle{width:42px;height:42px;border-radius:50%;background:#33A457;color:#fff;display:flex;align-items:center;justify-content:center;font-size:26px}
.ico-purple{color:#7C5CD6}.ico-red{color:#F0554F}.ico-blue{color:#3E86D8}
.ico-pink{color:#D95E97}.ico-amber{color:#E4972A}.ico-coral{color:#E07850}.ico-teal{color:#2AA588}

/* Comic + coloring */
.cc-row{display:grid;grid-template-columns:1fr 1fr;gap:24px}
.comic{border-radius:16px;overflow:hidden;background:linear-gradient(135deg,#EDE7FF,#FFD9E8)}
.comic img{display:block;width:100%;height:auto;object-fit:contain}
.coloring{width:100%;aspect-ratio:1/1;border-radius:18px;border:2px solid var(--card-border);background:#fff;display:flex;align-items:center;justify-content:center;font-size:96px;color:#C9C2E0;overflow:hidden}
.coloring img{width:100%;height:100%;object-fit:cover}

/* In-browser paint-bucket coloring studio */
.color-studio{display:flex;flex-direction:column;gap:14px}
.color-palette{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;padding:4px}
.swatch{width:32px;height:32px;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px var(--card-border);
  background:var(--sw);cursor:pointer;padding:0;transition:transform .12s,box-shadow .12s}
.swatch:hover{transform:scale(1.12)}
.swatch.selected{box-shadow:0 0 0 3px var(--purple);transform:scale(1.14)}
.coloring-canvas{width:100%;height:100%;display:block;cursor:crosshair;touch-action:none}
.color-tools{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.color-tool{flex:0 0 auto;width:auto;padding:0 16px;height:42px;font-size:14px}
.color-tool:disabled{opacity:.45;cursor:default}
.color-hint{text-align:center;font-size:13px;color:var(--muted)}

/* Custom colour swatch (native picker dressed up as a swatch) */
.swatch-custom{position:relative;display:flex;align-items:center;justify-content:center;
  background:conic-gradient(from 0deg,#F0554F,#FFCE5C,#33A457,#3E86D8,#7C5CD6,#F06BB0,#F0554F);color:#fff}
.swatch-custom .ti{font-size:16px;text-shadow:0 1px 2px rgba(0,0,0,.35);pointer-events:none}
.swatch-custom input{position:absolute;inset:0;opacity:0;cursor:pointer}

/* Tool bar (tools + brush size) */
.tool-bar{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;align-items:center}
.tool-btn,.size-btn{width:40px;height:40px;border-radius:12px;border:1.5px solid var(--card-border);background:#fff;
  color:var(--purple-deep);font-size:20px;cursor:pointer;display:flex;align-items:center;justify-content:center;
  transition:transform .12s,border-color .12s,background .12s}
.tool-btn:hover,.size-btn:hover{transform:translateY(-2px)}
.tool-btn.active,.size-btn.active{background:var(--purple-soft);border-color:var(--purple);color:var(--purple)}
.tool-divider{width:1px;height:26px;background:var(--card-border);margin:0 4px}

/* Smart-fill (gap tolerance) segmented control */
.gap-fill{display:flex;flex-direction:column;gap:8px;align-items:center}
.gap-fill-label{font-size:13.5px;font-weight:800;color:var(--purple-deep);display:flex;align-items:center;gap:6px}
.gap-fill-label .ti{color:var(--accent);font-size:17px}
.gap-fill-opts{display:flex;gap:6px;flex-wrap:wrap;justify-content:center}
.gap-btn{border:1.5px solid var(--card-border);background:#fff;color:var(--purple-deep);border-radius:12px;
  padding:7px 12px;font-family:inherit;font-size:13px;font-weight:700;cursor:pointer;transition:transform .12s,border-color .12s,background .12s}
.gap-btn:hover{transform:translateY(-2px)}
.gap-btn.active{background:var(--purple);border-color:var(--purple);color:#fff}
.size-dot{border-radius:50%;background:currentColor;display:block}

/* Sticker picker */
.sticker-picker{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
.sticker-btn{width:40px;height:40px;border-radius:12px;border:1.5px solid var(--card-border);background:#fff;
  font-size:22px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:transform .12s,border-color .12s}
.sticker-btn:hover{transform:translateY(-2px)}
.sticker-btn.active{border-color:var(--purple);background:var(--purple-soft)}

/* Coloring preview tile on the card — click opens the studio modal. */
.coloring-preview{position:relative;cursor:pointer;transition:transform .15s,box-shadow .15s}
.coloring-preview:hover{transform:translateY(-2px);box-shadow:0 16px 34px rgba(108,84,196,.22)}
.coloring-preview-badge{position:absolute;bottom:12px;left:50%;transform:translateX(-50%);
  background:var(--purple);color:#fff;font-weight:700;font-size:13.5px;padding:8px 16px;border-radius:999px;
  display:inline-flex;align-items:center;gap:6px;box-shadow:0 8px 18px rgba(124,92,214,.35);white-space:nowrap;pointer-events:none}
.coloring-preview-badge .ti{color:var(--accent)}

/* Coloring studio modal (the painting lightbox). Fills most of the screen:
   the canvas grows to the largest square that fits, controls sit alongside. */
.coloring-modal{position:relative;background:#fff;border-radius:24px;box-shadow:0 24px 60px rgba(46,34,92,.3);
  padding:22px;width:min(1100px,95vw);height:min(900px,95vh);display:flex;flex-direction:column;overflow:hidden}
.studio-main{flex:1;min-height:0;display:flex;gap:20px}
/* Stage is a size container; the frame uses 100cqmin → largest fitting square. */
.studio-stage{flex:1 1 auto;min-width:0;min-height:0;container-type:size;display:flex;align-items:center;justify-content:center}
.color-canvas-frame{width:100cqmin;height:100cqmin;aspect-ratio:1/1;border-radius:18px;border:2px solid var(--card-border);
  background:#fff;overflow:hidden;display:flex;align-items:center;justify-content:center}
.studio-controls{flex:0 0 250px;display:flex;flex-direction:column;gap:14px;overflow:auto;padding-top:46px;
  -webkit-user-select:none;user-select:none}

/* Narrow screens: stack controls under the canvas, size the canvas by width. */
@media(max-width:820px){
  .coloring-modal{width:100%;max-width:560px;height:auto;max-height:95vh;overflow:auto}
  .studio-main{flex-direction:column;overflow:visible}
  .studio-stage{container-type:normal;flex:0 0 auto}
  .color-canvas-frame{width:100%;height:auto}
  .studio-controls{flex:0 0 auto;overflow:visible;padding-top:0}
}

.ph-panel{aspect-ratio:1/1;border-radius:14px;border:2px dashed #E0D8F5;background:#FBFAFF;display:flex;align-items:center;justify-content:center;color:#CFC6EA;font-size:28px}
.ph-coloring{width:100%;aspect-ratio:1/1;border-radius:18px;border:2px dashed #E0D8F5;background:#FBFAFF;display:flex;align-items:center;justify-content:center;color:#CFC6EA;font-size:80px}

/* Feature bar */
.feature-bar{margin-top:24px;background:linear-gradient(90deg,#F1ECFF,#FFF6E4);border:1px solid var(--card-border);border-radius:24px;padding:18px 26px;box-shadow:var(--shadow)}
.feature-title{text-align:center;font-weight:800;font-size:16px;color:var(--purple-deep);margin-bottom:14px}
.feature-row{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}
.feature-items{display:flex;gap:28px;flex-wrap:wrap}
.feature{display:flex;flex-direction:column;align-items:center;gap:6px;font-weight:700;font-size:12.5px;color:var(--text);cursor:pointer}
.feature .ti{font-size:26px}
.mascot-msg{display:flex;align-items:center;gap:12px;font-weight:800;color:var(--purple-deep);font-size:14.5px}
.mascot{width:52px;height:52px;flex:none}

/* Image lightbox */
.main-img-wrap img,.g-thumb img,.ver-thumb img,.story-thumb img,.comic img,.coloring img,.child-preview img{cursor:zoom-in}
.lightbox{position:fixed;inset:0;background:rgba(46,34,92,0.74);backdrop-filter:blur(6px);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;padding:24px;z-index:100}
.lb-close{position:absolute;top:22px;left:22px;width:46px;height:46px;border-radius:50%;background:rgba(255,255,255,0.92);
  border:none;color:var(--text);font-size:24px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow)}
.lb-stage{display:flex;align-items:center;justify-content:center;gap:14px}
.lightbox-img{max-width:min(720px,80vw);max-height:70vh;border-radius:22px;background:#fff;object-fit:contain;box-shadow:0 24px 60px rgba(0,0,0,.4);touch-action:pan-y}
.lb-nav{width:48px;height:48px;flex:none;border-radius:50%;background:rgba(255,255,255,0.92);border:none;color:var(--purple-deep);
  font-size:24px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow);transition:transform .15s}
.lb-nav:hover{transform:scale(1.08)}
.lb-count{color:#fff;font-weight:700;font-size:14px;background:rgba(0,0,0,.28);padding:4px 12px;border-radius:12px}
.lb-title{color:#fff;font-weight:800;font-size:16px}
.lb-btn:disabled{opacity:.4;cursor:default}
.lb-btn:disabled:hover{background:transparent}
.lightbox-bar{display:flex;align-items:center;gap:8px;background:#fff;border-radius:20px;padding:12px 16px;box-shadow:var(--shadow)}
.lb-btn{display:flex;flex-direction:column;align-items:center;gap:4px;background:transparent;border:none;cursor:pointer;
  color:var(--purple-deep);font-weight:700;font-size:12px;padding:8px 14px;border-radius:14px;transition:.15s}
.lb-btn:hover{background:var(--purple-soft)}
.lb-btn .ti{font-size:22px}
.lb-btn.active{color:var(--danger)}
.lb-btn.danger{color:var(--danger)}
.lb-btn.danger:hover{background:#FEECEC}

/* Modal (improve image) */
.modal-overlay{position:fixed;inset:0;background:rgba(46,34,92,0.5);backdrop-filter:blur(4px);
  display:flex;align-items:center;justify-content:center;padding:24px;z-index:110}
.modal{background:#fff;border-radius:24px;box-shadow:0 24px 60px rgba(46,34,92,.3);padding:28px;width:100%;max-width:480px}

/* Games (puzzle + maze) */
.game-modal{--game-size:min(92vw,74vh,940px);position:relative;background:#fff;border-radius:24px;box-shadow:0 24px 60px rgba(46,34,92,.3);
  padding:24px;width:100%;max-width:min(96vw,1000px);max-height:94vh;overflow:auto;display:flex;flex-direction:column;align-items:center;gap:16px}
.game-head{text-align:center}
.game-title{font-size:22px;font-weight:800;color:var(--purple-deep);display:flex;align-items:center;justify-content:center;gap:8px}
.game-title .ti{color:var(--accent)}
.game-sub{font-size:14px;color:var(--muted);margin-top:4px;line-height:1.5}
.game-controls{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;align-items:center}
.game-btn{height:44px;padding:0 18px;font-size:14px}
.seg{display:inline-flex;gap:6px;background:var(--purple-soft);padding:4px;border-radius:14px}
.seg-btn{border:none;background:transparent;color:var(--purple-deep);border-radius:10px;padding:8px 14px;font-family:inherit;font-weight:700;font-size:13px;cursor:pointer;transition:background .12s,color .12s}
.seg-btn.active{background:var(--purple);color:#fff}
/* Win message is a temporary toast overlay so it never affects game layout/proportions. */
.game-win{position:fixed;top:38%;left:50%;z-index:2000;
  font-size:clamp(20px,3.4vw,30px);font-weight:800;color:var(--purple-deep);
  background:linear-gradient(90deg,rgba(241,236,255,.9),rgba(255,246,228,.9));
  backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);
  border:2px solid var(--card-border);border-radius:22px;padding:18px 32px;display:flex;align-items:center;gap:12px;
  box-shadow:0 22px 60px rgba(80,50,160,.38);pointer-events:none;max-width:calc(100vw - 32px);text-align:center;
  opacity:0;transform:translate(-50%,-50%) scale(.82);
  transition:opacity .28s ease,transform .28s cubic-bezier(.2,1.3,.5,1)}
.game-win.show-toast{opacity:1;transform:translate(-50%,-50%) scale(1)}
.game-win .ti{color:var(--accent);font-size:1.35em}
/* Game preview cards on the main page (each game in its own card) */
/* Game cards flow inside the two feature columns like every other tile. */
.game-card{display:flex;flex-direction:column;gap:14px}
.game-preview{position:relative;border:none;background:transparent;padding:0;cursor:pointer;font-family:inherit;
  border-radius:16px;overflow:hidden;transition:transform .15s,box-shadow .15s}
.game-preview:hover{transform:translateY(-3px);box-shadow:0 16px 34px rgba(108,84,196,.2)}
.game-preview-canvas{width:100%;aspect-ratio:1/1;display:block;background:#F3EEFF}
.game-preview-cta{position:absolute;bottom:12px;left:50%;transform:translateX(-50%);background:var(--purple);color:#fff;
  padding:10px 22px;border-radius:14px;font-weight:800;font-size:15px;display:inline-flex;align-items:center;gap:8px;
  box-shadow:0 8px 18px rgba(124,92,214,.45)}
.game-preview-cta .ti{color:#fff;font-size:18px}
.game-preview:hover .game-preview-cta{filter:brightness(1.08)}

/* Games strip — every game as a tap-to-play tile in one row that fills the full
   width (4 across on desktop). Wrapped in a .card so the tiles sit on a shared
   panel instead of floating; spans both feature columns. On mobile it wraps to a
   2-per-row grid. Tiles keep a square (1:1) aspect ratio at every size. */
.games-strip-wrap{grid-column:1/-1}
.games-strip{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}
.strip-game{position:relative;border:none;background:transparent;padding:0;cursor:pointer;font-family:inherit;
  border-radius:16px;overflow:hidden;transition:transform .15s,box-shadow .15s}
.strip-game:hover{transform:translateY(-3px);box-shadow:0 14px 30px rgba(108,84,196,.22)}
.strip-canvas{width:100%;aspect-ratio:1/1;display:block;background:#F3EEFF}
.strip-game-label{position:absolute;bottom:10px;left:50%;transform:translateX(-50%);
  background:rgba(255,255,255,.94);color:#5E3EBE;padding:6px 14px;border-radius:13px;font-weight:800;
  font-size:14px;display:inline-flex;align-items:center;gap:6px;white-space:nowrap;
  box-shadow:0 6px 14px rgba(124,92,214,.28)}
.strip-game-label .ti{color:var(--purple);font-size:16px}
@media(max-width:760px){.games-strip{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* Puzzle board */
/* direction:ltr so grid slots flow left-to-right and match the image columns
   (the page is RTL, which would otherwise mirror the columns). */
.puzzle-board{direction:ltr;width:var(--game-size);aspect-ratio:1/1;display:grid;gap:3px;background:var(--card-border);
  border-radius:16px;overflow:hidden;user-select:none;touch-action:manipulation}
.puzzle-tile{background-repeat:no-repeat;background-color:#fff;cursor:pointer;position:relative;transition:filter .1s}
.puzzle-tile:hover{filter:brightness(1.04)}
.puzzle-tile.sel{outline:4px solid var(--accent);outline-offset:-4px;z-index:2}
.puzzle-tile.correct::after{content:'';position:absolute;inset:0;box-shadow:inset 0 0 0 2px rgba(124,92,214,.4)}
/* Sliding-puzzle mode: one empty slot the neighbours slide into. */
.puzzle-tile.blank{background:#EEE9FB;cursor:default;box-shadow:inset 0 0 0 2px rgba(124,92,214,.15)}
.puzzle-tile.blank:hover{filter:none}
/* Jigsaw puzzle — canvas board of interlocking pieces (aspect set from image via JS) */
.jigsaw-stage{width:var(--game-size);aspect-ratio:1/1}
.jigsaw-canvas{width:100%;height:100%;border-radius:16px;background:#FBFAFF;border:2px solid var(--card-border);touch-action:manipulation;cursor:pointer;user-select:none}
/* Maze */
.maze-stage{width:var(--game-size);aspect-ratio:1/1}
.maze-canvas{width:100%;height:100%;border-radius:16px;background:#FBFAFF;border:2px solid var(--card-border);touch-action:none;cursor:crosshair}
/* Memory match — flip cards to find matching pairs across the gallery.
   Full game-size width (rows ≤ cols for every level, so the square-capped
   game-size keeps the whole board on screen without scrolling). */
.memory-grid{direction:ltr;width:var(--game-size);display:grid;gap:10px}
.memory-card{aspect-ratio:1/1;border:none;background:transparent;padding:0;cursor:pointer;font-family:inherit;perspective:600px}
.memory-inner{position:relative;width:100%;height:100%;transition:transform .35s;transform-style:preserve-3d}
.memory-card.flipped .memory-inner{transform:rotateY(180deg)}
.memory-card.matched .memory-inner{transform:rotateY(180deg) scale(.94)}
.memory-face{position:absolute;inset:0;border-radius:12px;backface-visibility:hidden;-webkit-backface-visibility:hidden;
  display:flex;align-items:center;justify-content:center;overflow:hidden}
.memory-back{background:linear-gradient(135deg,#7C5CD6,#B39BEE);color:#fff;font-size:26px}
.memory-back .ti{color:#fff}
.memory-front{background-color:#fff;background-repeat:no-repeat;background-size:cover;background-position:center;transform:rotateY(180deg);box-shadow:inset 0 0 0 2px var(--card-border)}
.memory-card.matched .memory-front{box-shadow:inset 0 0 0 3px var(--purple)}
.memory-card:disabled{cursor:default}
.memory-moves{font-weight:700;font-size:13px;color:var(--muted);min-width:72px;text-align:center}
/* Scratch-off reveal — image underneath, an erasable cover canvas on top */
.scratch-stage{position:relative;width:var(--game-size);aspect-ratio:1/1;border-radius:16px;overflow:hidden;
  border:2px solid var(--card-border);background:#FBFAFF}
.scratch-img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;user-select:none;-webkit-user-drag:none;pointer-events:none}
.scratch-canvas{position:absolute;inset:0;width:100%;height:100%;touch-action:none;cursor:crosshair}
.modal-title{font-size:20px;font-weight:800;color:var(--purple-deep);display:flex;align-items:center;justify-content:center;gap:8px;text-align:center}
.modal-title .ti{color:var(--purple2)}
.modal-sub{font-size:14px;color:var(--muted);text-align:center;margin:8px 0 16px;line-height:1.6}
.modal-actions{display:flex;gap:12px;margin-top:16px}
.modal-actions .btn{flex:1}

/* Improve-image loading state — a clearly animated "we're working" step. */
.improve-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:14px;text-align:center;padding:22px 10px 8px;min-height:210px}
/* Spinning ring with a gently pulsing wand at its center. */
.magic-loader{position:relative;width:72px;height:72px;display:flex;align-items:center;justify-content:center}
.magic-loader .spinner{width:72px;height:72px}
.magic-loader-icon{position:absolute;color:var(--purple);font-size:30px;animation:wand-pulse 1.4s ease-in-out infinite}
@keyframes wand-pulse{0%,100%{transform:scale(.9) rotate(-8deg);opacity:.75}50%{transform:scale(1.12) rotate(8deg);opacity:1}}
/* Indeterminate progress bar so it never looks frozen. */
.improve-progress{width:180px;max-width:70%;height:7px;border-radius:999px;background:#EDE7FB;overflow:hidden;margin-top:4px}
.improve-progress span{display:block;height:100%;width:40%;border-radius:999px;
  background:linear-gradient(90deg,var(--purple2),var(--purple));animation:progress-slide 1.3s ease-in-out infinite}
@keyframes progress-slide{0%{margin-inline-start:-40%}100%{margin-inline-start:100%}}
.improve-loading .loading-p{transition:opacity .3s}

/* Version thumbnails: main one is highlighted, others are pickable */
.ver .ver-main-tag{display:inline-flex;align-items:center;gap:3px;color:var(--purple)}

/* Gentle image animation on the saved gallery */
.g-thumb img{transition:transform .3s}
[data-portfolio]:hover .g-thumb img{transform:scale(1.05)}

/* Full-screen magical loading overlay (visible on any scroll position/viewport) */
.loading-overlay{position:fixed;inset:0;z-index:130;display:flex;align-items:center;justify-content:center;padding:24px;
  background:radial-gradient(120% 90% at 50% 8%,#F3ECFF 0%,#EDE6FF 55%,#F6F1FF 100%);backdrop-filter:blur(6px);animation:welcomeFade .3s ease both}
.lo-inner{display:flex;flex-direction:column;align-items:center;gap:16px;text-align:center;width:min(92vw,420px)}

/* Mascot stage: unicorn floating, ringed by sparkles */
.lo-stage{position:relative;width:220px;height:190px;display:flex;align-items:center;justify-content:center}
.lo-mascot{width:170px;height:170px;position:relative;z-index:2;
  filter:drop-shadow(0 12px 22px rgba(108,84,196,0.28));animation:floaty 3.5s ease-in-out infinite}
.lo-spark{position:absolute;color:var(--accent);z-index:3;font-size:18px;opacity:.9;animation:lo-twinkle 2.6s ease-in-out infinite}
.lo-spark .ti{display:block}
.lo-spark.s1{top:6px;left:26%;font-size:26px;color:#FFCE5C;animation-delay:0s}
.lo-spark.s2{top:22px;right:18%;font-size:16px;color:var(--purple2);animation-delay:.5s}
.lo-spark.s3{top:64px;left:12%;font-size:20px;color:#C9A8FF;animation-delay:1s}
.lo-spark.s4{top:44px;right:10%;font-size:22px;color:#FFE08A;animation-delay:1.4s}
.lo-spark.s5{top:96px;right:24%;font-size:14px;color:#8FC7FF;animation-delay:1.9s}
@keyframes lo-twinkle{0%,100%{opacity:.25;transform:scale(.7)}50%{opacity:1;transform:scale(1.1)}}

.lo-title{font-size:26px;font-weight:800;color:var(--purple-deep);margin-top:-4px}
.lo-sub{font-size:15px;color:var(--muted);max-width:320px;line-height:1.6}

/* Magical gradient progress bar */
.lo-progress-row{display:flex;align-items:center;gap:12px;width:100%;margin-top:2px}
.lo-progress{position:relative;flex:1;height:22px;border-radius:999px;background:#EDE7FB;
  box-shadow:inset 0 1px 3px rgba(108,84,196,0.14);overflow:visible}
.lo-progress-fill{position:relative;height:100%;width:0;border-radius:999px;transition:width .5s cubic-bezier(.4,0,.2,1);
  background:linear-gradient(90deg,#9B7BEF 0%,#C86DD6 38%,#F06AA8 62%,#FFB25C 88%,#FFCE5C 100%);
  background-size:200% 100%;animation:lo-bar-shimmer 2.4s linear infinite;
  box-shadow:0 3px 10px rgba(240,106,168,0.4)}
.lo-progress-star{position:absolute;top:50%;right:-6px;transform:translateY(-50%);color:#FFCE5C;font-size:26px;
  filter:drop-shadow(0 2px 4px rgba(240,160,60,0.6));animation:lo-star-bob 1.4s ease-in-out infinite}
@keyframes lo-bar-shimmer{to{background-position:200% 0}}
@keyframes lo-star-bob{0%,100%{transform:translateY(-50%) rotate(-8deg)}50%{transform:translateY(-62%) rotate(8deg)}}
.lo-progress-pct{font-size:18px;font-weight:800;color:var(--purple-deep);min-width:46px;text-align:left;font-variant-numeric:tabular-nums}

/* Rotating status pill */
.lo-status{display:inline-flex;align-items:center;gap:8px;background:#fff;border:1.5px solid var(--card-border);
  border-radius:999px;padding:10px 20px;box-shadow:0 8px 20px rgba(108,84,196,0.12);max-width:100%}
.lo-status-emoji{font-size:18px}
.lo-status-text{font-size:15px;font-weight:700;color:var(--purple);transition:opacity .3s}

/* Magic tip box */
.lo-tip{display:flex;align-items:flex-start;gap:12px;text-align:right;background:rgba(255,255,255,0.55);
  border:1.5px dashed #D9CCF6;border-radius:18px;padding:14px 18px;max-width:100%}
.lo-tip-icon{font-size:22px;line-height:1.4}
.lo-tip-title{font-size:14px;font-weight:800;color:var(--purple-deep)}
.lo-tip-text{font-size:13.5px;color:var(--muted);line-height:1.55;margin-top:2px}

/* Streamed preview of the character forming, shown in the creation overlay. */
.lo-preview{position:relative;z-index:2;width:min(58vw,190px);aspect-ratio:1/1;object-fit:cover;border-radius:24px;
  box-shadow:0 14px 36px rgba(108,84,196,0.28);border:3px solid #fff;animation:pop-in .3s ease both}
/* Smaller streamed preview for the in-card loaders (improve / add-child). */
.gen-preview{width:min(70%,200px);aspect-ratio:1/1;object-fit:cover;border-radius:18px;margin:12px auto 0;
  box-shadow:0 10px 26px rgba(108,84,196,0.22);border:3px solid #fff;animation:pop-in .3s ease both}
@keyframes pop-in{from{opacity:0;transform:scale(.92)}to{opacity:1;transform:none}}

/* User-area dropdown menu (gear) */
.user-menu{position:relative}
.user-dropdown{position:absolute;top:52px;left:0;min-width:210px;background:#fff;border:1px solid var(--card-border);
  border-radius:16px;box-shadow:0 14px 40px rgba(108,84,196,.18);padding:8px;z-index:60}
.ud-item{display:flex;align-items:center;gap:10px;width:100%;background:transparent;border:none;cursor:pointer;
  padding:11px 12px;border-radius:12px;font-family:inherit;font-weight:700;font-size:14px;color:var(--text);text-align:right;text-decoration:none}
.ud-item:hover{background:var(--purple-soft)}
.ud-item .ti{font-size:20px;color:var(--purple2)}
/* Admin-only link — set apart from the regular menu items. */
.ud-admin{color:var(--purple);margin-bottom:4px;padding-bottom:12px;border-bottom:1px solid var(--card-border);border-radius:12px 12px 0 0}
.ud-admin .ti{color:var(--purple)}
/* Disconnect — set apart at the bottom, styled as a destructive action. */
.ud-signout{color:var(--danger);margin-top:4px;padding-top:12px;border-top:1px solid var(--card-border);border-radius:0 0 12px 12px}
.ud-signout .ti{color:var(--danger)}
.ud-signout:hover{background:#FDECEC}

/* Full-page views (jokes) */
.page-view{position:fixed;inset:0;z-index:120;overflow:auto;padding:56px 24px;
  background:linear-gradient(180deg,#F5F1FF 0%,#FBF9FF 45%,#F6F1FF 100%);animation:welcomeFade .35s ease both}
.pv-close{position:fixed;top:22px;left:22px;width:46px;height:46px;border-radius:50%;background:#fff;border:1px solid var(--card-border);
  color:var(--text);font-size:24px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow);z-index:2}
.pv-inner{max-width:760px;margin:0 auto}
.pv-head{text-align:center;margin-bottom:32px}
.pv-title{font-size:32px;font-weight:800;color:var(--purple);display:flex;align-items:center;justify-content:center;gap:10px}
.pv-title .ti{color:var(--accent)}
.pv-sub{font-size:16px;color:var(--muted);font-weight:600;margin-top:6px}
.pv-empty{text-align:center;color:var(--muted);font-size:15px;line-height:1.7;margin-top:24px;display:flex;flex-direction:column;align-items:center;gap:14px}
/* "With the kids" gallery */
#kidsView .pv-inner{max-width:1000px}
.kids-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:20px}
.kids-card{border:1px solid var(--card-border);background:#fff;border-radius:20px;overflow:hidden;cursor:pointer;padding:0;
  font-family:inherit;box-shadow:var(--shadow);transition:transform .15s,box-shadow .15s;display:flex;flex-direction:column}
.kids-card:hover{transform:translateY(-4px);box-shadow:0 18px 40px rgba(108,84,196,.22)}
.kids-card-img{width:100%;aspect-ratio:1/1;overflow:hidden;background:#F3EEFF}
.kids-card-img img{width:100%;height:100%;object-fit:cover;display:block}
.kids-card-name{display:flex;align-items:center;justify-content:center;gap:6px;font-weight:800;font-size:15px;color:var(--purple-deep);padding:12px 10px}
.kids-card-name .ti{color:var(--accent);font-size:18px}

/* Coloring-book viewer (in-app; replaces the old separate-tab print window) */
.cb-actions{display:flex;justify-content:center;align-items:center;gap:12px;flex-wrap:wrap;margin:-16px 0 10px}
.cb-selbtn{border:1px solid var(--card-border);background:#fff;color:var(--purple-deep);font-weight:800;font-size:14px;border-radius:999px;padding:10px 18px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;font-family:inherit}
.cb-selbtn:hover{background:var(--purple-soft)}
.cb-hint{text-align:center;color:var(--muted);font-size:13.5px;font-weight:600;margin:0 0 24px}
#coloringBookPrint:disabled{opacity:.5;cursor:not-allowed}
.cb-pages{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:20px}
.cb-page{position:relative;border:1px solid var(--card-border);background:#fff;border-radius:20px;overflow:hidden;box-shadow:var(--shadow);cursor:pointer;transition:transform .12s,box-shadow .12s,border-color .12s}
.cb-page:hover{transform:translateY(-2px)}
.cb-page:focus-visible{outline:2px solid var(--purple);outline-offset:3px}
.cb-page.selected{border-color:var(--purple);box-shadow:0 0 0 3px rgba(124,92,214,0.22),var(--shadow)}
.cb-page:not(.selected) .cb-thumb{opacity:.45}
.cb-page:not(.selected) .cb-name{color:var(--muted)}
.cb-check{position:absolute;top:10px;inset-inline-start:10px;z-index:2;width:26px;height:26px;border-radius:50%;background:#fff;border:2px solid var(--card-border);color:#fff;display:flex;align-items:center;justify-content:center;font-size:15px;transition:background .12s,border-color .12s}
.cb-page.selected .cb-check{background:var(--purple);border-color:var(--purple)}
.cb-page:not(.selected) .cb-check i{display:none}
.cb-thumb{width:100%;aspect-ratio:1/1;overflow:hidden;background:#fff;display:flex;align-items:center;justify-content:center}
.cb-thumb img{width:100%;height:100%;object-fit:contain}
.cb-name{text-align:center;font-weight:800;font-size:15px;color:var(--purple-deep);padding:12px 10px}

.joke-row{display:flex;align-items:center;gap:16px;background:#fff;border:1px solid var(--card-border);border-radius:20px;
  box-shadow:var(--shadow);padding:16px 18px;margin-bottom:16px;cursor:pointer;transition:transform .15s,box-shadow .15s}
.joke-row:hover{transform:translateY(-2px);box-shadow:0 14px 34px rgba(108,84,196,.16)}
.joke-row-thumb{width:66px;height:66px;flex:none;border-radius:16px;overflow:hidden;background:#F3EEFF}
.joke-row-thumb img{width:100%;height:100%;object-fit:cover}
.joke-row-body{flex:1;min-width:0}
.joke-row-name{font-weight:800;font-size:14px;color:var(--purple-deep);margin-bottom:3px}
.joke-row-text{font-size:15px;line-height:1.6;color:var(--text)}
.joke-row-play{flex:none;width:48px;height:48px;border-radius:50%;border:none;background:var(--purple);color:#fff;
  font-size:22px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 6px 14px rgba(124,92,214,.35)}
.joke-row-play:hover{filter:brightness(1.05)}
/* Secondary "go to this creature's page" button on every "all-…" row. */
.joke-row-goto{flex:none;width:48px;height:48px;border-radius:50%;border:1.5px solid var(--card-border);background:#fff;
  color:var(--purple);font-size:20px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:.15s}
.joke-row-goto:hover{background:var(--purple-soft);border-color:var(--purple2)}

/* Welcome / creation-picker entrance experience */
.welcome{position:fixed;inset:0;z-index:120;overflow:auto;padding:56px 24px;
  background:linear-gradient(180deg,#F5F1FF 0%,#FBF9FF 45%,#F6F1FF 100%);
  display:flex;align-items:flex-start;justify-content:center;animation:welcomeFade .45s ease both}
@keyframes welcomeFade{from{opacity:0}to{opacity:1}}
.wc-spark{position:fixed;color:var(--accent);font-size:22px;opacity:.8;animation:floaty 5s ease-in-out infinite}
.welcome-inner{max-width:1000px;width:100%}
.welcome-head{text-align:center;margin-bottom:40px}
/* Book shortcuts at the top of the gallery page (shown with many creations) */
.welcome-books{display:flex;flex-wrap:wrap;justify-content:center;gap:12px;margin:-16px 0 32px}
.wb-item{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid var(--card-border);border-radius:16px;
  padding:11px 18px;font-family:inherit;font-weight:800;font-size:14px;color:var(--purple-deep);cursor:pointer;
  box-shadow:var(--shadow);transition:transform .15s,box-shadow .15s}
.wb-item:hover{transform:translateY(-3px);box-shadow:0 14px 34px rgba(108,84,196,.16)}
.wb-item .ti{font-size:20px}
.welcome-mascot{width:104px;height:104px;margin:0 auto 12px;animation:floaty 4s ease-in-out infinite}
.welcome-title{font-size:36px;font-weight:800;color:var(--purple);display:flex;align-items:center;justify-content:center;gap:10px}
.welcome-title .ti{color:var(--accent)}
.welcome-sub{font-size:18px;color:var(--muted);font-weight:600;margin-top:6px}
/* Auth strip on the gallery (the gallery overlays the header, so sign-in lives here too) */
.welcome-auth{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:12px;margin-top:16px}
.welcome-auth .wa-note{font-size:14px;font-weight:700;color:var(--muted);display:inline-flex;align-items:center;gap:6px}
.welcome-auth .wa-note .ti{color:var(--purple2)}
.welcome-auth .wa-google{display:inline-flex;align-items:center;min-height:40px}
.welcome-auth .wa-btn{display:inline-flex;align-items:center;gap:8px;background:var(--purple);color:#fff;border:none;
  border-radius:14px;padding:10px 20px;font-family:inherit;font-weight:800;font-size:14px;cursor:pointer;
  box-shadow:0 8px 18px rgba(124,92,214,.35);transition:filter .15s}
.welcome-auth .wa-btn:hover{filter:brightness(1.05)}
.welcome-auth .wa-chip{display:inline-flex;align-items:center;gap:8px;background:var(--purple-soft);color:var(--purple-deep);
  border:1px solid var(--card-border);border-radius:999px;padding:6px 14px 6px 6px;font-size:13px;font-weight:700}
.welcome-auth .wa-chip b{color:var(--purple-deep)}
/* Signed-in chip is now a menu button (avatar + sync + caret) with a dropdown. */
.welcome-auth .wa-account{position:relative;display:inline-flex}
.welcome-auth button.wa-chip{cursor:pointer;font-family:inherit;transition:filter .15s}
.welcome-auth button.wa-chip:hover{filter:brightness(.98)}
.welcome-auth .wa-caret{font-size:14px;opacity:.6}
.welcome-auth button.wa-chip[aria-expanded="true"] .wa-caret{transform:rotate(180deg)}
.wa-menu{position:absolute;top:calc(100% + 8px);left:50%;transform:translateX(-50%);z-index:30;
  display:flex;flex-direction:column;gap:2px;min-width:190px;padding:6px;background:#fff;
  border:1px solid var(--card-border);border-radius:14px;box-shadow:0 14px 34px rgba(0,0,0,.16)}
.wa-menu-name{padding:6px 12px 8px;font-size:12px;font-weight:700;color:var(--muted);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:240px;
  border-bottom:1px solid var(--card-border);margin-bottom:2px}
.wa-menu-item{display:flex;align-items:center;gap:9px;width:100%;background:#fff;border:none;
  border-radius:10px;padding:10px 12px;font-family:inherit;font-size:14px;font-weight:700;
  color:var(--text);text-align:start;text-decoration:none;cursor:pointer;transition:background .12s}
.wa-menu-item:hover{background:var(--purple-soft)}
.wa-menu-item .ti{font-size:18px}
.wa-menu-signout{color:var(--danger)}
.wa-menu-signout:hover{background:#FDECEC}
.welcome-auth .wa-admin{display:inline-flex;align-items:center;gap:6px;background:#fff;border:1.5px solid var(--purple);
  color:var(--purple);border-radius:12px;padding:7px 14px;font-weight:800;font-size:13px;text-decoration:none}
.welcome-auth .wa-admin:hover{background:var(--purple-soft)}
.welcome-auth .wa-signout{display:inline-flex;align-items:center;justify-content:center;background:#fff;
  border:1.5px solid var(--card-border);color:var(--muted);border-radius:12px;padding:7px 10px;
  font-family:inherit;font-size:15px;cursor:pointer;transition:color .15s,border-color .15s}
.welcome-auth .wa-signout:hover{color:var(--danger);border-color:var(--danger)}
.wa-avatar{width:28px;height:28px;border-radius:50%;overflow:hidden;background:#D8E9FF;flex:none;
  display:flex;align-items:center;justify-content:center;color:#4B86D8}
.wa-avatar img{width:100%;height:100%;object-fit:cover}
.welcome-auth .wa-sync{color:var(--purple2);font-size:15px;opacity:.7}
.welcome-auth .wa-chip-mini{padding:5px 12px 5px 5px;gap:6px}
/* Returning, signed-in user doesn't need the full splash — collapse the hero into
   a single inline row: mascot + greeting on one line, the auth chip alongside
   (wrapping under it only when there isn't room). Subtitle is dropped as redundant. */
.welcome.is-authed .welcome-head{position:relative;z-index:20;display:flex;flex-wrap:wrap;
  align-items:center;justify-content:center;gap:10px 16px;margin-bottom:26px}
.welcome.is-authed .welcome-mascot{width:52px;height:52px;margin:0;animation:none}
.welcome.is-authed .welcome-title{font-size:25px}
.welcome.is-authed .welcome-sub{display:none}
/* Auth controls pinned to the right corner (RTL start) — greeting stays centered. */
.welcome.is-authed .welcome-auth{position:absolute;top:50%;right:0;transform:translateY(-50%);
  margin:0;width:auto;flex-wrap:nowrap}
.welcome.is-authed .wa-admin{padding:7px 10px}
.welcome-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:22px}
.wc-card{cursor:pointer;opacity:0;animation:cardIn .55s cubic-bezier(.2,.85,.25,1) forwards}
.wc-inner{background:#fff;border:1px solid var(--card-border);border-radius:24px;padding:16px;
  box-shadow:var(--shadow);transition:transform .18s,box-shadow .18s}
.wc-card:hover .wc-inner{transform:translateY(-6px);box-shadow:0 18px 42px rgba(108,84,196,.22)}
.wc-thumb{width:100%;aspect-ratio:1/1;border-radius:18px;overflow:hidden;background:#F3EEFF;
  display:flex;align-items:center;justify-content:center;animation:floaty 5s ease-in-out infinite}
.wc-thumb img{width:100%;height:100%;object-fit:cover;transition:transform .3s}
.wc-card:hover .wc-thumb img{transform:scale(1.07)}
.wc-name{text-align:center;font-weight:800;font-size:16px;margin-top:12px;display:flex;align-items:center;justify-content:center;gap:6px}
.wc-fav{color:var(--danger)}
.wc-new .wc-thumb{background:var(--purple-soft);color:var(--purple);border:2px dashed #D9CEF7;
  font-size:46px;flex-direction:column;gap:6px;animation:none}
.wc-new .wc-name{color:var(--purple)}
@keyframes cardIn{from{opacity:0;transform:translateY(28px) scale(.92)}to{opacity:1;transform:none}}
@keyframes floaty{0%,100%{transform:translateY(0)}50%{transform:translateY(-7px)}}
@media(prefers-reduced-motion:reduce){
  .welcome,.wc-card,.wc-thumb,.welcome-mascot,.wc-spark,.lo-mascot,.loading-overlay{animation:none}
  .wc-card{opacity:1}
}

@media(max-width:1080px){.grid{grid-template-columns:1fr}.lower{grid-template-columns:minmax(0,1fr)}}

/* ===== Mobile / tablet ===== */
@media(max-width:760px){
  .wrap{padding:18px 14px}
  /* Stack the main two-column layouts into one column. minmax(0,1fr) — not 1fr —
     so tracks can shrink below content min-content and never blow out the page. */
  .grid2{grid-template-columns:minmax(0,1fr)}
  .cc-row{grid-template-columns:minmax(0,1fr)}
  /* 3-across action grids become 2-across. */
  .actions{grid-template-columns:repeat(2,minmax(0,1fr))}
  /* Grid/flex children must be allowed to shrink, or their content forces width. */
  .col,.card,.lower>*,.grid2>*{min-width:0}
  /* Login banner stacks and its buttons go full width. */
  .login-card{flex-direction:column;align-items:stretch;text-align:center}
  .login-actions{justify-content:center}
  .login-actions .google-btn,.login-actions .ghost-btn{width:100%}
  /* Smaller gallery/welcome tiles fit narrow screens. */
  .welcome-grid{grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:14px}
  .gallery{grid-template-columns:repeat(auto-fill,minmax(120px,1fr))}
  /* The lightbox action bar has 5 buttons — let it wrap. */
  .lightbox-bar{flex-wrap:wrap;justify-content:center}
  .feature-bar{padding:16px 16px}
  /* Modals: don't let tall ones overflow the screen. */
  .modal-overlay{padding:14px}
  .modal{max-height:90vh;overflow:auto}
  /* Long inspiration chips wrap instead of pushing the page wide. */
  .idea-chip{max-width:100%}
  /* Feature rows with a fixed-size thumb stack so nothing gets squeezed off-screen. */
  .story-row,.child-row{flex-direction:column;align-items:stretch}
  .ph-story-thumb,.story-thumb{width:100%;max-width:180px;height:auto;aspect-ratio:1/1;margin:0 auto}
  /* Trim the welcome overlay padding on small screens. */
  .welcome{padding:28px 14px}
  .welcome-title{font-size:28px}
  .welcome-mascot{width:84px;height:84px}
  /* Signed-in: the hero shrinks hard so the picker sits near the top. */
  .welcome.is-authed{padding:18px 14px}
  .welcome.is-authed .welcome-head{margin-bottom:16px;gap:8px 12px}
  .welcome.is-authed .welcome-mascot{width:44px;height:44px}
  .welcome.is-authed .welcome-title{font-size:21px}
}

/* Tighter header on phones: keep avatar · brand · home, drop the clutter. */
@media(max-width:560px){
  .header-inner{height:auto;padding:10px 14px;gap:8px}
  .header-side{gap:8px}
  .brand-title{font-size:20px}
  .brand-title .ti{font-size:18px}
  .brand-logo{width:30px;height:30px}
  .brand-sub{display:none}
  .user-meta{display:none}
  /* Keep the gear visible so the menu (incl. disconnect) stays reachable. */
  .gear{width:38px;height:38px;font-size:18px}
  /* Anchor to the profile's (right) edge so the menu can't spill off-screen. */
  .user-dropdown{top:48px;right:0;left:auto}
  .h-avatar{width:38px;height:38px;font-size:20px}
  .home-btn{padding:8px 12px;font-size:13px}
  .mock-toggle-label{display:none}
}

/* --- Shared (read-only) view: viewing someone else's creation via a link --- */
.shared-cta{display:none}
body.shared-view .shared-cta{display:flex;flex-direction:column;align-items:center;gap:12px;
  margin-top:18px;padding:18px;border-radius:16px;
  background:linear-gradient(135deg,#EEF2FF,#F5ECFF);border:1px solid #E3E0F5}
.shared-cta-text{font-size:15px;font-weight:800;color:#5E3EBE;text-align:center}
.shared-cta-btn{display:inline-flex;align-items:center;gap:8px;padding:12px 22px;border:0;
  border-radius:999px;background:linear-gradient(135deg,#6B4EE6,#8A5CF6);color:#fff;
  font-size:15px;font-weight:800;cursor:pointer;box-shadow:0 8px 20px rgba(107,78,230,.35)}
.shared-cta-btn:hover{filter:brightness(1.05)}
.shared-report{display:inline-flex;align-items:center;gap:6px;background:none;border:0;cursor:pointer;
  color:#8A82A6;font:inherit;font-size:12.5px;font-weight:700;padding:4px 8px}
.shared-report:hover{color:#d1495b}
.shared-report:disabled{color:#1f9d6b;cursor:default}
/* Hide owner-only chrome when just viewing a shared creation. */
body.shared-view #actionsPanel,
body.shared-view .fav-btn,
body.shared-view .share-btn,
body.shared-view #nameEditBtn,
body.shared-view #syncBadge,
body.shared-view .signin-note,
/* Versions strip is owner-only (it includes the "new version" tile) — a visitor
   sees only the chosen main image. */
body.shared-view #mainVersions,
/* Lightbox edit controls: a visitor must never fav/delete (delete would hit the
   viewer's OWN active creation). Keep share/download/print. */
body.shared-view #lbFav,
body.shared-view #lbDelete,
/* Hide only the empty "generate this" prompts — a visitor can't create. Games
   and any already-created content stay; empty feature cards are hidden in JS. */
body.shared-view .gen-cta{display:none !important}
/* Collapse the now-empty left column so the image spans full width. */
body.shared-view #mainGrid.grid2{grid-template-columns:minmax(0,1fr)}
/* Without the side dashboard the square image can exceed the screen. Let the
   viewport be the limit: cap the image at ~88vh (a small margin so it never
   touches the top/bottom edges) and to the content width, and center it. Any
   name/CTA around it may scroll — the picture stays the star. */
body.shared-view .main-img-wrap{max-width:min(100%,88vh);margin-inline:auto}
/* Feather the picture's side edges so they melt into the bleed instead of
   ending on a hard border. The wrap goes transparent at the edges and the
   image's sides fade out, revealing the matching blurred bleed behind. */
body.shared-view .main-img-wrap{background:transparent}
body.shared-view #mainImg{
  -webkit-mask-image:linear-gradient(to right,transparent 0,#000 10%,#000 90%,transparent 100%);
          mask-image:linear-gradient(to right,transparent 0,#000 10%,#000 90%,transparent 100%)}

/* ===== Cover layout (feature flag COVER_LAYOUT, shared view only) ===========
   Toggled by adding body.cover-view (see setViewerReadOnly in app.js). When
   off, the original shared view above is used unchanged; when on, the original
   #stateCreated children are hidden and .cover-shell renders instead: the image
   on the left, a purple bleed overlapping its right edge, and the actions on the
   purple like a cover. Classes are cv-* to avoid clashing with app styles. */
.cover-shell{display:none}
body.cover-view .cover-shell{display:block}
body.cover-view #stateCreated{padding:0;background:transparent;border:0;box-shadow:none}
body.cover-view #stateCreated > *:not(.cover-shell){display:none !important}

.cv-cover{position:relative;width:100%;aspect-ratio:16/9;border-radius:26px;overflow:hidden;
  background:#E4D6F8;box-shadow:var(--shadow);isolation:isolate}
/* Full-height square keeps the original 1:1 image whole and undistorted. */
.cv-photo{position:absolute;inset:0 auto 0 0;height:100%;aspect-ratio:1/1}
.cv-photo img{width:100%;height:100%;display:block;object-fit:cover}
/* The bleed fades the image into a soft lavender (a touch deeper than the site
   bg), overlapping just the photo's right ~18%. Text on it is dark for contrast. */
.cv-veil{position:absolute;inset:0;pointer-events:none;z-index:1;
  background:linear-gradient(90deg,
    rgba(228,214,248,0)   40%,
    rgba(228,214,248,.5)  49%,
    rgba(228,214,248,.88) 56%,
    #E4D6F8               62%,
    #E4D6F8              100%)}
/* Soft top-right highlight so the lavender reads rich, not flat/washed. */
.cv-veil::after{content:"";position:absolute;inset:0;pointer-events:none;
  background:radial-gradient(85% 70% at 80% 16%, rgba(255,255,255,.4), rgba(255,255,255,0) 55%)}
.cv-panel{position:absolute;left:42%;right:0;top:0;bottom:0;z-index:2;color:var(--text);
  display:flex;flex-direction:column;justify-content:center;gap:14px;
  padding:30px 124px 30px 22px;text-align:right}
.cv-eyebrow{font-size:13px;font-weight:800;color:var(--purple-deep);display:inline-flex;align-items:center;gap:6px}
.cv-eyebrow .ti{color:var(--accent)}
.cv-titlerow{display:flex;align-items:center;gap:12px}
.cv-title{font-family:'Secular One','Assistant',sans-serif;font-weight:400;
  font-size:clamp(26px,3.4vw,42px);line-height:1.08;color:var(--purple-deep);letter-spacing:.2px}
.cv-play{flex:none;width:42px;height:42px;border-radius:50%;border:0;cursor:pointer;
  background:#fff;color:var(--purple);display:grid;place-items:center;font-size:20px;
  box-shadow:0 6px 16px rgba(46,34,92,.16);transition:transform .12s,background .15s}
.cv-play:hover{transform:scale(1.06);background:#F5F1FF}
.cv-play:active{transform:scale(.96)}
.cv-subtitle{font-size:clamp(13px,1.5vw,16px);font-weight:600;color:var(--muted);max-width:24ch;line-height:1.35}
.cv-cta{margin-top:4px;align-self:flex-start;display:inline-flex;align-items:center;gap:9px;
  padding:12px 24px;border:0;border-radius:999px;cursor:pointer;font-size:15px;font-weight:800;color:#fff;
  background:linear-gradient(135deg,var(--purple),#8A5CF6);box-shadow:0 10px 24px rgba(107,78,230,.35)}
.cv-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}
.cv-report{align-self:flex-start;display:inline-flex;align-items:center;gap:6px;background:none;border:0;cursor:pointer;
  color:var(--muted);font:inherit;font-size:12.5px;font-weight:700;padding:2px 0}
.cv-report:hover{color:var(--danger)}
.cv-report:disabled{color:#1f9d6b;cursor:default}

/* Floating white action rail pinned to the right (share/favorite/games/…). */
.cv-rail{position:absolute;top:50%;right:16px;transform:translateY(-50%);z-index:3;
  background:#fff;border-radius:22px;box-shadow:0 16px 36px rgba(46,34,92,.18);
  display:flex;flex-direction:column;padding:4px}
.cv-rail-btn{display:flex;flex-direction:column;align-items:center;gap:5px;width:78px;
  padding:12px 6px;background:none;border:0;cursor:pointer;border-radius:16px;
  color:var(--text);font:inherit;font-size:11.5px;font-weight:800;transition:background .15s}
.cv-rail-btn:not(:last-child){box-shadow:inset 0 -1px 0 #F1ECFA}
.cv-rail-btn:hover{background:#F5F1FF}
.cv-rail-btn .ti{font-size:23px}
.cv-rail-btn.r-share .ti{color:#2F9E6B}
.cv-rail-btn.r-fav .ti{color:var(--purple)}
.cv-rail-btn.r-fav.active .ti{color:var(--danger)}
.cv-rail-btn.r-games .ti{color:#3B82F6}
.cv-rail-btn.r-color .ti{color:#EC6FA6}
.cv-rail-btn.r-story .ti{color:#F1A73B}
.cv-rail-btn.r-print .ti{color:var(--purple-deep)}

/* Owner-only controls appear only when the creation cover is active; viewer-only
   controls (make-your-own, report) hide there. */
body:not(.cover-create) .cv-owner{display:none !important}
body.cover-create .cv-viewer{display:none !important}

/* ---- Cover on the owner's own creation page (feature flag COVER_CREATE) ----
   Reuses the same .cover-shell as the shared view. Shows the cover as the hero,
   drops the big actions panel, and keeps the versions + who-can-see controls
   below it. Flag off → none of this applies and the original view returns. */
body.cover-create .cover-shell{display:block}
body.cover-create #stateCreated > .creature-name-row,
body.cover-create #stateCreated > .img-stage{display:none !important}
body.cover-create #actionsPanel{display:none !important}
/* Collapse the two-column grid to one so the cover spans full width — only once
   created (during the wizard the left column must stay visible). */
body.cover-create #mainGrid.created.grid2{grid-template-columns:minmax(0,1fr)}
body.cover-create #mainGrid.created > .col:first-child{display:none}

/* Versions strip + who-can-see control tucked into the cover panel (moved there
   by positionCoverExtras). Compact + right-aligned; they wrap below the panel's
   own content, so if there's no room they fall below the cover, never above. */
/* RTL: flex-start is the RIGHT side, keeping these in the clean lavender under
   the CTA rather than over the picture (flex-end would push them left). */
.cv-panel .versions-inline{margin-top:6px;padding-top:0;border-top:0;
  justify-content:flex-start;flex-wrap:wrap;gap:8px;max-width:100%;overflow:visible}
.cv-panel .versions-inline .ver{width:48px}
.cv-panel .versions-inline .ver-thumb{width:48px;height:48px;border-width:2px;font-size:22px}
.cv-panel .versions-inline .ver-label{display:none}
.cv-panel .vis-control{margin-top:2px;justify-content:flex-start;flex-wrap:wrap;gap:8px}

@media(max-width:720px){
  .cv-cover{aspect-ratio:auto;display:flex;flex-direction:column}
  .cv-photo{position:relative;inset:auto;width:100%;height:auto;aspect-ratio:1/1}
  .cv-veil{display:none}
  .cv-panel{position:relative;inset:auto;left:auto;right:auto;padding:18px 18px 20px;text-align:center;align-items:center}
  .cv-cta{align-self:stretch;justify-content:center}
  .cv-panel .versions-inline,.cv-panel .vis-control{justify-content:center}
  /* Horizontal rail on mobile: wrap so 5–6 buttons never overflow the viewport,
     and drop the divider lines (they look odd once the row wraps). */
  .cv-rail{position:relative;inset:auto;right:auto;top:auto;transform:none;flex-direction:row;flex-wrap:wrap;
    justify-content:center;gap:2px;max-width:100%;box-sizing:border-box;margin:0 auto 16px;border-radius:18px}
  .cv-rail-btn{width:60px}
  .cv-rail-btn:not(:last-child){box-shadow:none}
  /* Print is the least-used and reachable elsewhere — drop it when space is tight. */
  .cv-rail-btn.r-print{display:none}
}

/* Section header above the creations grid — "my creations" + a light link to the public gallery. */
.welcome-section-head{display:flex;align-items:center;justify-content:space-between;gap:12px;
  flex-wrap:wrap;margin:0 2px 14px}
.welcome-section-head .wsh-title{font-size:16px;font-weight:800;color:var(--purple-deep)}
.welcome-gallery{display:inline-flex;align-items:center;gap:4px;text-decoration:none;
  color:#5E3EBE;font-weight:700;font-size:13px;transition:color .15s}
.welcome-gallery .ti{font-size:16px}
.welcome-gallery:hover{color:#4A2FA0}

/* --- Sign-in-to-share popup --- */
.share-auth{max-width:420px;text-align:center;position:relative}
.share-auth .modal-title{justify-content:center}
.sa-x{position:absolute;top:12px;left:12px;width:34px;height:34px;border-radius:50%;border:0;
  background:#F1EEF8;color:#6A6480;cursor:pointer;font-size:16px;display:grid;place-items:center}
.sa-x:hover{background:#E7E2F3}
.sa-google{display:flex;justify-content:center;margin:18px 0 6px;min-height:44px}
.sa-or{display:flex;align-items:center;color:#8A82A6;font-size:13px;font-weight:800;margin:10px 0}
.sa-or::before,.sa-or::after{content:"";flex:1;height:1px;background:#E6E3F0}
.sa-or span{padding:0 12px}
.sa-fallback{width:100%;justify-content:center}

/* --- Visibility control (who can see this creation) --- */
.vis-control{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:10px;margin-top:14px}
.vis-caption{display:inline-flex;align-items:center;gap:5px;font-size:13px;font-weight:800;color:#8A82A6}
.vis-caption .ti{font-size:15px}
.vis-select{font:inherit;font-size:13px;font-weight:800;color:#2E225C;background:#fff;
  border:1px solid #E6E3F0;border-radius:999px;padding:7px 14px;cursor:pointer}
.vis-select:hover{border-color:#C9BCF2}
.vis-select:focus{outline:2px solid #EEE8FB;border-color:#8A5CF6}
.vis-copy{display:inline-flex;align-items:center;gap:6px;font:inherit;font-size:13px;font-weight:800;
  color:#5E3EBE;background:#EEE8FB;border:0;border-radius:999px;padding:7px 14px;cursor:pointer}
.vis-copy:hover{filter:brightness(.97)}
body.shared-view .vis-control{display:none !important}
/* Mobile: keep it to one tidy row — icons only, no wrapping. */
@media(max-width:560px){
  .vis-control{gap:8px;flex-wrap:nowrap;margin-top:12px}
  .vis-caption-text,.vis-copy-text{display:none}
  .vis-caption .ti{font-size:18px}
  .vis-select{padding:7px 12px;max-width:40vw}
  .vis-copy{padding:8px 11px}
}

/* App toast (share-link feedback, etc.). */
.app-toast{position:fixed;left:50%;bottom:26px;transform:translateX(-50%) translateY(12px);
  background:#2E225C;color:#fff;padding:12px 22px;border-radius:999px;font-size:14px;font-weight:800;
  box-shadow:0 12px 32px rgba(46,34,92,.34);opacity:0;pointer-events:none;
  transition:opacity .2s,transform .2s;z-index:300;max-width:88vw;text-align:center}
.app-toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

/* --- Customer feedback: floating button + modal --- */
.feedback-fab{position:fixed;left:20px;bottom:20px;z-index:250;width:52px;height:52px;border-radius:50%;
  border:none;background:#3E86D8;color:#fff;font-size:22px;display:grid;place-items:center;cursor:pointer;
  box-shadow:0 8px 22px rgba(62,134,216,.4);transition:transform .15s,box-shadow .15s}
.feedback-fab:hover{transform:translateY(-2px);box-shadow:0 12px 28px rgba(62,134,216,.5)}
.feedback-fab i{pointer-events:none}
.feedback-modal{position:fixed;inset:0;z-index:400;display:flex;align-items:center;justify-content:center;padding:18px}
.fbm-backdrop{position:absolute;inset:0;background:rgba(20,25,45,.5)}
.fbm-panel{position:relative;background:#fff;border-radius:18px;padding:26px 24px 22px;width:min(460px,94vw);
  box-shadow:0 24px 60px rgba(20,25,45,.3);max-height:92vh;overflow:auto}
.fbm-close{position:absolute;top:12px;left:12px;border:none;background:transparent;color:#8a93a6;font-size:20px;cursor:pointer;padding:4px}
.fbm-title{margin:0 0 4px;font-size:21px;color:#1f2430}
.fbm-sub{margin:0 0 16px;font-size:14px;color:#5b6472}
.fbm-label{display:block;font-size:13px;font-weight:700;color:#33405c;margin:12px 0 5px}
.fbm-select,.fbm-textarea{width:100%;border:1px solid #d9deea;border-radius:10px;padding:10px 12px;font:inherit;
  font-size:15px;color:#1f2430;background:#fff;box-sizing:border-box}
.fbm-textarea{resize:vertical;min-height:96px;line-height:1.5}
.fbm-select:focus,.fbm-textarea:focus{outline:none;border-color:#3E86D8;box-shadow:0 0 0 3px rgba(62,134,216,.15)}
.fbm-hp{position:absolute;left:-9999px;width:1px;height:1px;opacity:0}
.fbm-consent{display:flex;align-items:flex-start;gap:8px;margin:14px 0 0;font-size:13.5px;color:#5b6472;cursor:pointer}
.fbm-consent input{margin-top:3px}
.fbm-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}
.fbm-cancel,.fbm-send{border-radius:10px;padding:9px 18px;font:inherit;font-weight:700;font-size:14px;cursor:pointer}
.fbm-cancel{border:1px solid #d9deea;background:#fff;color:#5b6472}
.fbm-cancel:hover{background:#f4f6fb}
.fbm-send{border:none;background:#3E86D8;color:#fff;display:inline-flex;align-items:center;gap:6px}
.fbm-send:hover{background:#356fbb}
.fbm-send:disabled{opacity:.55;cursor:default}
