/* Family studio and the touch-first game room */
:root { --family-paper:#fffaf2; --family-line:#dfd9cb; --room:#181428; --room-card:#282239; --room-line:#49405e; --room-copy:#f7f1ff; --room-soft:#cdc2e1; }
body, .topbar { background-color:var(--family-paper); }
body [data-screen=home] .hero { max-width:1240px; gap:clamp(26px,5vw,76px); padding-block:clamp(30px,4vw,64px); }
body .hero h1 { font-size:clamp(3.8rem,6.2vw,6.2rem); line-height:1.02; letter-spacing:-.068em; }
body .hero .lead { max-width:32ch; font-weight:440; color:#4d495d; line-height:1.52; }
.hero-actions { margin-top:4px; }
body .hero-art { max-width:520px; padding:4% 4% 7% 9%; }
body .hero-mat { inset:1% 0 1% 2%; border-radius:24px 84px 20px 66px; background-color:#dfddf1; background-size:14px 14px; }
body .hero-orbit { transform:rotate(-26deg); }
body .home-card { background:#292442; transform:rotate(2deg); padding:9px; border-radius:16px; }
body .home-card figcaption { min-height:35px; justify-content:center; }
body .original-print { width:26%; bottom:-1%; left:0; }
.original-print img { height:auto; }
h1[tabindex="-1"]:focus { outline:none; }
body .home-board { aspect-ratio:1; }
.home-board button { touch-action:none; }
.worlds-section { padding-block:clamp(30px,4.5vw,66px); background:#f3f1e8; border-block:1px solid var(--family-line); }
.section-intro { display:flex; align-items:baseline; justify-content:space-between; gap:8px 20px; margin-bottom:23px; flex-wrap:wrap; }
.section-intro h2 { font-size:clamp(2.1rem,3.6vw,3.4rem); }
.section-intro p,.studio-heading p { color:var(--muted); font-size:1.03rem; }
.world-shelf { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:clamp(10px,1.8vw,24px); }
.world-postcard { display:grid; grid-template-areas:"photo" "label"; background:var(--white); padding:6px 6px 0; border-radius:15px; border:1px solid #d5cee0; color:var(--ink); overflow:hidden; text-align:start; transition:transform .18s,box-shadow .18s; }
.world-postcard:hover,.world-postcard:focus-visible { transform:translateY(-3px); box-shadow:0 8px 18px #2214371a; }
.world-postcard img { width:100%; aspect-ratio:1.8; object-fit:cover; border-radius:10px; }
.world-postcard span { font-weight:740; padding:9px 7px 11px; font-size:1.02rem; }
body .story-inner { padding-block:clamp(32px,5vw,78px); }
.family-studio { max-width:1160px; }
.studio-heading { margin-bottom:26px; }
.studio-heading h1 { font-size:clamp(2.4rem,4.7vw,4.3rem); margin-bottom:9px; }
.builder-layout { display:grid; grid-template-columns:minmax(0,1.55fr) minmax(240px,.82fr); gap:clamp(24px,4.5vw,68px); align-items:start; }
.builder-form { min-width:0; }
.builder-section { display:block; border:0; padding:0; margin:0 0 21px; min-inline-size:0; }
.builder-section legend,.builder-section h2 { font-size:1.15rem; font-weight:800; letter-spacing:-.025em; line-height:1.35; padding:0; margin:0 0 9px;}
.photo-pick { display:flex; gap:18px; align-items:center; padding:14px 18px; background:#f1eef9; border:1.5px dashed #a397c5; border-radius:15px; }
.photo-pick small,.photo-pick p { margin-top:8px; }
.photo-pick .btn { min-height:44px; }
.photo-pick .photo-list:empty,.photo-pick.has-photos .photo-symbol { display:none; }
.photo-pick .photo-list { display:flex; flex-wrap:wrap; gap:4px; max-width:48%; }
.photo-pick .photo-list img { width:clamp(42px,5vw,65px); height:auto; aspect-ratio:1; object-fit:cover; border:3px solid #fff; border-radius:8px; box-shadow:0 2px 4px #2013341b; }
.photo-symbol { display:block; flex:none; position:relative; width:52px; height:45px; border:2px solid #705c9b; background:#dcd5f3; border-radius:7px; transform:rotate(-5deg); overflow:hidden; }
.photo-symbol:before { content:""; position:absolute; width:9px;height:9px;border-radius:50%;background:#f7a968;top:7px;left:9px; }
.photo-symbol i,.photo-symbol:after { content:""; position:absolute; width:38px;height:29px; background:#8877b2; transform:rotate(40deg); bottom:-16px;left:0; }
.photo-symbol:after { background:#69548d; left:22px; bottom:-15px; }
.age-choices,.world-choices,.style-choices { display:grid; gap:7px; }
.age-choices { grid-template-columns:repeat(4,minmax(0,1fr)); }
.style-choices { grid-template-columns:repeat(2,minmax(0,1fr)); }
.world-choices { grid-template-columns:repeat(4,minmax(0,1fr)); }
.choice { position:relative; display:flex; align-items:center; justify-content:center; border:1px solid #c8c2d0; border-radius:10px; background:#fffdf9; color:var(--ink); padding:8px; min-height:45px; cursor:pointer; font-size:.96rem; text-align:center; }
.choice input { position:absolute; width:1px;height:1px;overflow:hidden;clip-path:inset(50%); }
.choice:has(input:focus-visible) { outline:3px solid #697fe9; outline-offset:2px; }
.choice:has(input:checked) { border-color:#574ad0; background:#eeecff; box-shadow:inset 0 0 0 1px #574ad0; }
.choice strong { font-weight:690; }
.choice-style { display:grid; grid-template-columns:auto 1fr; grid-template-rows:auto auto; text-align:start; justify-content:start; column-gap:12px; padding:11px 13px; }
.choice-style strong { align-self:end; }
.choice-style small { color:#5a536c; font-size:.84rem; align-self:start; }
.style-glyph { grid-row:1/3; color:#5142a2; font-style:normal; font-size:1.58rem; line-height:1; }
.glyph-tray { font-family:system-ui,sans-serif; font-size:1.38rem; }
.branch-note { font-size:.92rem; color:#5e546d; margin-top:7px; }
.choice-world { flex-direction:column; gap:6px; padding:4px 4px 6px; min-height:42px; font-size:.83rem; }
.choice-world img { width:100%; height:57px; object-fit:cover; border-radius:7px; }
.choice-world:last-child { grid-column:1/-1; border-style:dashed; min-height:42px; padding:6px 14px; justify-self:start; }
.concept-field { margin-top:13px; }
.builder-section.image-options { margin:4px 0 8px; background:#f5f2eb; border:1px solid var(--family-line); border-radius:11px; }
.image-options h2 { padding:10px 14px 0; }
.image-settings { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.image-fields [data-field=beta-balance] { color:#494079; font-weight:650; }
@media(max-width:410px) { .image-settings { grid-template-columns:1fr; } }
.image-fields { display:grid; gap:10px; padding:0 14px 12px; }
.image-routes legend { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.image-routes { border:0; padding:0; margin:0; display:grid; gap:8px; min-width:0; }
.image-route { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:10px; cursor:pointer; min-height:65px; padding:6px 9px; border:1px solid #c8c2d0; border-radius:10px; background:#fffdf9; }
.image-route:has(input:checked) { border-color:#574ad0; background:#f2efff; box-shadow:inset 0 0 0 1px #574ad0; }
.image-route:has(input:focus-visible) { outline:3px solid #697fe9; outline-offset:2px; }
.image-route input { accent-color:#574ad0; width:19px; height:19px; margin:0; }
.image-route small,.image-route strong { display:block; line-height:1.35; }
.image-route small { font-size:.83rem; color:#5e546d; margin-top:3px; }
.image-route img { border-radius:7px; width:54px; height:54px; object-fit:cover; }
.original-puzzle-thumb { position:relative; overflow:hidden; border-radius:7px; }
.original-puzzle-thumb img { display:block; }
.original-puzzle-thumb::after { content:""; position:absolute; inset:0; background:linear-gradient(90deg,transparent 49%,#fff8 49%,#fff8 51%,transparent 51%),linear-gradient(transparent 49%,#fff8 49%,#fff8 51%,transparent 51%); pointer-events:none; }
.image-route:has(input:disabled) { opacity:.65; cursor:default; }
.photo-thumb { display:grid; justify-items:center; }
.photo-thumb button { min-height:44px; min-width:44px; border:0; background:none; color:#5a4c74; text-decoration:underline; font:inherit; font-size:.8rem; cursor:pointer; }
.reference-agreement { margin:8px 0; }
.family-membership { max-width:620px; margin-inline:auto; display:grid; gap:16px; }
.family-membership .actions { flex-wrap:wrap; }
.studio-privacy { padding:4px 0 13px; }
.builder-submit { display:flex; align-items:center; flex-wrap:wrap; gap:6px 14px; }
.builder-submit span { color:var(--muted); font-size:.85rem; }
.builder-submit .error { width:100%; }
.builder-preview { position:sticky; top:20px; border-radius:18px; background:#242440; color:#fff9ee; overflow:hidden; box-shadow:0 12px 34px #16132c18; }
.preview-art { background:#32324d; }
.preview-art img { width:100%; aspect-ratio:1.22; object-fit:cover; }
.preview-content { padding:22px; }
.idea-preview { margin:10px 0 0; padding:10px 13px; background:#f1ecfb; color:#30224c; border-inline-start:3px solid #8064aa; border-radius:6px; overflow-wrap:anywhere; }
.idea-preview strong, .game-premise strong { margin-inline-end:.5em; }
.game-premise { color:var(--room-soft); font-size:.95rem; line-height:1.5; padding:8px 2px 12px; overflow-wrap:anywhere; }
.game-premise strong { color:var(--room-copy); }
.preview-content>p { color:#d6cdec; font-size:.93rem; }
.preview-content h2 { margin:3px 0 7px; font-size:clamp(1.9rem,3vw,2.65rem); }
.preview-route { display:flex; justify-content:space-between; align-items:center; gap:5px; margin-top:18px; }
.preview-route span { display:grid; justify-items:center; flex:1; border-top:2px solid #aba3c1; padding-top:6px; }
.preview-route strong { color:#edd2a0; font-size:1.38rem; }
.preview-route small { font-size:.78rem; }
body[data-room=true] { background:var(--room); }
body[data-room=true] .topbar { color:var(--room-copy); background:#1c172c; border-color:var(--room-line); }
body[data-room=true] .topbar-inner { min-height:54px; }
body[data-room=true] .brand,body[data-room=true] .brand small { color:var(--room-copy); }
body[data-room=true] footer { display:none; }
.top-share { min-height:40px; background:#352943; border-color:#5d4b71; color:white; padding:5px 14px; font-size:.91rem; }
.game-room { color:var(--room-copy); background:radial-gradient(ellipse at 78% -8%,#372446,transparent 54%),var(--room); min-height:calc(100svh - 54px); }
.room-wrap { width:min(100%,1080px); margin:auto; padding:clamp(15px,2.2vw,30px) clamp(10px,4vw,40px) max(22px,env(safe-area-inset-bottom)); }
.chapter-banner { position:relative; isolation:isolate; overflow:hidden; display:flex; justify-content:space-between; align-items:center; gap:12px; border:1px solid #594468; border-radius:15px; min-height:105px; padding:14px 22px; background:#382745; }
.chapter-banner::before { content:""; position:absolute; z-index:-1; inset:0; background-image:linear-gradient(to left,#302038 10%,#352641ee 38%,#36244645 76%,#29193932),var(--chapter-art);background-size:cover;background-position:center 52%; }
.chapter-kicker { color:#dfd0ed; font-size:.91rem;font-weight:650; }
.chapter-banner h1 { font-size:clamp(1.6rem,3.6vw,3rem);letter-spacing:-.055em; margin-top:2px; }
.chapter-count,.remaining { display:inline-flex; background:#493448; color:#ffdc9f; padding:3px 9px; border:1px solid #715744; font-size:.85rem; font-weight:700; border-radius:7px; white-space:nowrap; }
.room-grid { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); grid-template-areas:"board tray" "notes notes"; align-items:start; gap:12px; margin-top:13px; }
.room-grid[data-style=swap],.room-grid[data-complete=true] { grid-template-areas:"board notes"; }
.room-board,.room-tray,.room-notes { min-width:0; border:1px solid var(--room-line); background:var(--room-card); border-radius:16px; padding:12px; }
.room-board { grid-area:board; }
.room-tray { grid-area:tray; }
.room-notes { grid-area:notes; padding:16px; }
.room-notes p { max-width:58ch; }
.panel-bar { display:flex; align-items:center; justify-content:space-between; gap:6px; min-height:39px; margin-bottom:7px; }
.panel-bar strong { font-size:1rem; }
.board-buttons { display:flex; gap:5px; }
.board-buttons button,.change-demo { color:var(--room-copy); background:#362c49; border:1px solid #625372;font:inherit; font-size:.88rem; border-radius:8px; min-width:45px; min-height:42px; padding:5px 9px; }
.board-buttons button[aria-pressed=true] { background:#514365; }
.puzzle-surface { position:relative; width:100%; margin:auto; }
.puzzle-surface .board { width:100%; border-radius:10px; color:var(--room-copy); gap:2px; }
.puzzle-surface .board>button { touch-action:none; }
.peek-photo { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; z-index:3; border-radius:10px; pointer-events:none; }
.solve-meter { display:flex; gap:10px; align-items:center; padding-top:8px; font-weight:650; font-size:.83rem; }
.solve-meter progress { background:#463a52; border:none; border-radius:8px; height:7px; flex:1; min-width:0; accent-color:#c2a6f1; overflow:hidden; }
.solve-meter progress::-webkit-progress-bar { background:#473854; border-radius:8px; }
.solve-meter progress::-webkit-progress-value { background:#c3a5eb; border-radius:8px; }
.solve-meter progress::-moz-progress-bar { background:#c3a5eb; }
.game-status,.play-note { color:#e2d7ee; font-size:1rem; }
.game-status:not(:empty) { margin-top:4px; color:#ffdc9b; }
.game-actions:not(:empty) { margin-block-start:8px; }
.game-actions .btn,.change-demo { min-height:44px; }
.change-demo { margin-top:7px; background:transparent; }
.reveal-panel { border-inline-start:3px solid #ddc091; padding-inline-start:11px; margin:10px 0 14px; }
.reveal-panel p { color:#cfbadc; font-size:.87rem; }
.reveal-panel strong { font-size:1.12rem; }
.room-board .difficulty { margin-top:7px; }
@media(max-width:760px) {
  body [data-screen=home] .hero { gap:16px; padding-block:26px 25px; }
  body .hero h1 { font-size:clamp(3rem,10.5vw,4.5rem); }
  body .hero-copy { gap:10px; }
  body .hero .lead { font-size:1.05rem; max-width:37ch; }
  .hero-actions { gap:8px; }
  body .hero-art { max-width:345px; padding:3% 4.5% 5% 8%; }
  .worlds-section {padding-block:25px 32px;}
  .section-intro { margin-bottom:13px; }
  .world-shelf { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .world-postcard img { aspect-ratio:1.8; }
  .world-postcard span { font-size:.94rem; padding:7px 5px; }
  .builder-layout { display:block; }
  .builder-preview { display:none; }
  .builder-section { margin-bottom:18px; }
  .studio-heading { margin-bottom:20px; }
  .studio-heading h1 { font-size:2.35rem; }
  .family-studio { padding-bottom:max(20px,env(safe-area-inset-bottom)); }
  .builder-submit { position:sticky; bottom:0; z-index:3; margin-inline:calc(-1 * var(--gutter)); padding:9px var(--gutter) max(10px,env(safe-area-inset-bottom)); border-top:1px solid var(--family-line);background:var(--family-paper); }
  .builder-submit .btn { flex:1; min-height:46px; }
  .builder-submit span { max-width:16ch;line-height:1.3; }
  .choice-style { column-gap:7px; padding:9px; }
  .room-wrap { padding:7px max(7px,env(safe-area-inset-left)) max(18px,env(safe-area-inset-bottom)); }
  body[data-room=true] .topbar-inner { min-height:48px; padding-inline:12px; }
  body[data-room=true] .brand { font-size:1.4rem; min-height:44px; }
  body[data-room=true] .brand-icon { transform:scale(.84); }
  .chapter-banner { padding:8px 12px; min-height:57px; border-radius:11px; }
  .chapter-banner h1 { font-size:clamp(1.35rem,5.4vw,1.85rem); }
  .chapter-kicker { font-size:.82rem; }
  .room-grid,.room-grid[data-style=swap],.room-grid[data-complete=true] { display:flex; flex-direction:column; align-items:stretch; gap:7px; margin-top:7px; }
  .room-board,.room-tray,.room-notes { border-radius:12px; padding:8px; }
  .room-board { order:0; }
  .room-tray { order:1; }
  .room-notes { order:2; }
  .panel-bar { margin-bottom:4px; min-height:30px; }
  .board-buttons button { min-height:44px; }
  .puzzle-surface { max-width:min(100%,64svh); }
  .room-grid[data-style=swap] .puzzle-surface { max-width:min(100%,52svh); }
  .solve-meter {padding-top:5px;}
  .room-notes { padding:10px 12px; }
  .room-grid[data-complete=true] .room-notes { background:#322a40; }
}
@media(max-width:380px) {
  .family-studio {--gutter:14px;}
  .age-choices,.world-choices,.style-choices {gap:4px;}
  .choice-age {font-size:.85rem;padding:5px 3px;}
  .choice-world {font-size:.76rem;}
  .photo-pick { padding:10px; gap:10px; }
}
@media(prefers-reduced-motion:reduce) { .world-postcard:hover { transform:none; } }

.tray-help { color:var(--room-soft); font-size:.88rem; margin:0 0 7px; }
.room-board .game-status { font-size:.9rem; }
.room-notes[hidden] { display:none; }

.image-check { display:flex; gap:9px; align-items:flex-start; line-height:1.45; padding-block:7px; font-size:.95rem; cursor:pointer; }
.image-check input { width:20px; height:20px; flex:none; margin:2px 0 0; accent-color:var(--blue); }

.device-keys,.email-code-fields { display:grid; gap:10px; }
.builder-options { margin:0 0 18px; padding:0 14px; border:1px solid var(--family-line); border-radius:11px; }
.builder-options summary,.family-account summary { padding:12px 0; min-height:44px; cursor:pointer; font-weight:700; }
.builder-options summary small { display:block; margin-inline-start:1.2em; color:var(--muted); font-size:.875rem; font-weight:400; }
.builder-options .image-settings { margin:2px 0 16px; }
.builder-options .builder-section { margin-bottom:14px; }
.guest-library { max-width:32rem; }
.family-account { margin-top:20px; }
.library-list button { min-height:44px; }
.auth-panel details summary { cursor:pointer; padding:8px 0; min-height:44px; }

.auth-provider { display:flex; align-items:center; justify-content:center; gap:11px; width:100%; min-height:50px; padding:10px 16px; border:1px solid #b8b4bb; border-radius:12px; background:white; color:#232135; font:inherit; font-weight:700; cursor:pointer; }
.auth-provider:hover, .auth-provider:focus-visible { border-color:var(--blue); }
.mail-provider { background:var(--family-paper,#fffaf2); }
.mail-provider span[aria-hidden] { font-size:1.25em; color:var(--blue); }
.email-code-fields:not([hidden]) { margin-block:14px 4px; }
.device-keys > button { width:100%; margin-block:4px; }
.auth-panel .device-keys { display:block; }
.auth-panel .device-keys[hidden] { display:none; }
.auth-panel .device-keys summary { color:var(--muted); font-size:.95rem; }
.analytics-consent { position:fixed; z-index:30; inset-inline-start:12px; bottom:max(12px,env(safe-area-inset-bottom)); width:min(29rem,calc(100% - 24px)); padding:18px; background:#fffaf2; border:1px solid #c3bdc8; border-radius:16px; box-shadow:0 6px 24px #21163825; }
.analytics-consent p { font-size:.9rem; line-height:1.5; margin:6px 0 12px; }
.analytics-consent .actions { flex-wrap:wrap; }
.analytics-consent button { min-height:44px; }
.privacy-page { max-width:46rem; padding-block:clamp(32px,7vw,72px); line-height:1.75; }
.privacy-page h1 { font-size:clamp(2.2rem,6vw,3.5rem); line-height:1.16; }
.privacy-page h2 { margin:1.7em 0 .3em; font-size:1.3rem; }
.privacy-page p { margin:0 0 1em; }
