/* Shape colours: a deep tone for light backgrounds, a pale tone for dark ones. */
:root { --deep: #3F6E8C; --pale: #9FC3D9; }
[data-shape-color="green"] { --deep: #3F7358; --pale: #A5D0B4; }
[data-shape-color="plum"]  { --deep: #75507F; --pale: #CDB3D6; }
[data-shape-color="clay"]  { --deep: #A9503A; --pale: #E3B3A2; }
[data-shape-color="slate"] { --deep: #55606B; --pale: #BFC8D0; }
[data-shape-color="red"]    { --deep: #CF3F2E; --pale: #F2A79C; }
[data-shape-color="orange"] { --deep: #C95F0A; --pale: #F3BE8A; }
[data-shape-color="pink"]   { --deep: #CF3D86; --pale: #F0A8CB; }
[data-shape-color="teal"]   { --deep: #0A716C; --pale: #8FD6D0; }
[data-shape-color="purple"] { --deep: #7650C8; --pale: #C4B0F0; }
[data-shape-color="blue"]   { --deep: #3F6E8C; --pale: #9FC3D9; }

/* Palettes. Shape against background is at least 3:1, except "soft", which an adult chooses on purpose. */
:root, [data-palette="light"] {
  --bg: #EEF1EC; --shape: var(--deep); --on-shape: #F4F7F5;
  --ink: #2E3A40; --soft: #C9D2CD; --panel: #FFFFFF;
}
[data-palette="dark"] {
  --bg: #1E2530; --shape: var(--pale); --on-shape: #1E2530;
  --ink: #D8DEE4; --soft: #3A4656; --panel: #283140;
}
[data-palette="warm"] {
  --bg: #F4EADB; --shape: var(--deep); --on-shape: #FBF4EA;
  --ink: #3B2E28; --soft: #DCCDB8; --panel: #FFFAF2;
}
[data-palette="soft"] {
  --bg: #E6E9E5; --shape: #9AAFBB; --shape: color-mix(in srgb, var(--deep) 45%, #E6E9E5); --on-shape: #F1F3F0;
  --ink: #4A555A; --soft: #D3D9D4; --panel: #EEF0ED;
}
[data-palette="sky"] {
  --bg: #D9F0FF; --shape: var(--deep); --on-shape: #FFFFFF;
  --ink: #17324A; --soft: #A8D2EC; --panel: #FFFFFF;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#status { position: fixed; top: 0; left: 0; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
h1:focus, #gate:focus { outline: none; }
a { color: inherit; }

/* ---------- Child screen ---------- */
#child { height: 100vh; height: 100dvh; min-height: 340px; display: flex; flex-direction: column; gap: 10px; user-select: none; -webkit-user-select: none; touch-action: manipulation; overflow: hidden;
  padding: max(12px, var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) max(16px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px))) max(12px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))) max(16px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px))); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.tool { width: 80px; height: 80px; flex: none; display: grid; place-items: center; background: var(--panel); border: 2px solid var(--soft); border-radius: 22px; }
.tool svg { width: 44px; height: 44px; fill: currentColor; }
.tool.small { height: 60px; width: auto; min-width: 60px; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px; border-radius: 16px; }
.tool.small svg { width: 32px; height: 32px; }
#sound .waves, #sound[aria-pressed="true"] .slash { display: none; }
#sound[aria-pressed="true"] .waves { display: inline; }
#sound.gone { visibility: hidden; }
#undo { margin-left: auto; } #undo.gone { visibility: hidden; }
/* What to do now gets the room. Beside it, smaller, what comes next. */
#stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: clamp(10px, 3vw, 40px); --now: min(54vw, 40vh); --pair: min(38vw, 40vh); }
.card { text-align: center; flex: none; width: var(--now); position: relative; }
.card .pic { position: relative; background: #fff; border: 6px solid var(--shape); border-radius: 28px; padding: 8%; }
.card.next { width: calc(var(--now) * .58); } .card.next .pic { border: 4px solid var(--soft); border-radius: 22px; }
.card svg { display: block; width: 100%; }
.card .word, .card .label { margin: 4px 0 0; font-weight: 700; font-size: clamp(19px, 3vh, 30px); line-height: 1.15; overflow-wrap: break-word; margin-inline: -24px; }
.card.next .word { font-size: clamp(16px, 2.2vh, 22px); font-weight: 600; }
.card .label { font-size: clamp(15px, 2vh, 20px); font-weight: 600; margin: 0 0 4px; }
.two .card, .two .card.next { width: var(--pair); } .two .card.next .pic { border-width: 5px; } .two .card.next .word { font-size: clamp(19px, 3vh, 30px); font-weight: 700; }
.arrow { width: clamp(26px, 5vw, 52px); flex: none; opacity: .6; }
/* The plan changed: the old picture, small and crossed out, in the corner. */
.was { position: absolute; top: -10px; left: -10px; width: 40%; min-width: 48px; z-index: 1; background: #fff; border: 3px solid #E98A2B; border-radius: 14px; padding: 3px; }
.was::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent calc(50% - 3px), #C0392B calc(50% - 3px), #C0392B calc(50% + 3px), transparent calc(50% + 3px)); border-radius: 12px; }
.was + * { display: block; }
.time { height: 16px; margin: 8px 4px 0; border: 3px solid var(--shape); border-radius: 10px; background: var(--panel); overflow: hidden; }
.time i { display: block; height: 100%; background: var(--shape); transform-origin: left; }
.time.over { border-color: #E98A2B; }
.joy { display: none; } .happy .joy { display: inline; } .happy .look { display: none; }
#end { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: nowrap; }
#end .happy { width: min(38vw, 36vh); } #end .star { width: min(11vw, 9vh); fill: #EFAA00; }
#end .ok { width: min(46vw, 40vh); }
[data-motion="move"] #end .star { animation: appear 1.2s ease-out both; }
@keyframes appear { from { opacity: 0; transform: scale(.6); } }
#foot { display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 84px; flex: none; }
.go { width: 150px; height: 84px; border: 0; border-radius: 26px; background: var(--shape); color: var(--on-shape); display: grid; place-items: center; }
.go svg { width: 54px; height: 54px; }
#clock svg { width: 48px; height: 48px; }
/* All the steps, small. Finished ones fade and get a tick. The animal stands on the one to do now. */
#strip { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; align-items: flex-end; gap: 6px; flex: none; --m: min(72px, calc((100vw - 32px - 6px * (var(--n) - 1)) / var(--n)), 11vh); padding-top: calc(var(--m) * .62); }
#strip.plain-strip { padding-top: 0; }
#strip li { width: var(--m); height: var(--m); position: relative; flex: none; }
#strip .pic { height: 100%; background: #fff; border: 3px solid var(--soft); border-radius: 22%; padding: 8%; display: block; }
#strip .pic > svg { display: block; width: 100%; height: 100%; }
#strip .now .pic { border-color: var(--shape); border-width: 4px; }
#strip .over .pic > svg { opacity: .28; }
#strip .over::after { content: ""; position: absolute; inset: 22%; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M8 25l11 11 21-25' fill='none' stroke='%233C7A39' stroke-width='8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
#strip .rider { position: absolute; left: 12%; width: 76%; bottom: calc(100% - 6px); }
[data-motion="move"] #strip .rider.hop { animation: hop .6s ease-out; }
@keyframes hop { 0% { transform: translateX(calc(-100% - 12px)); } 50% { transform: translateX(-50%) translateY(-45%); } 100% { transform: none; } }

/* ---------- Gate and controls ---------- */
#gate { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px 20px; }
#gate p { max-width: 28em; margin: 0; }
#gate-hold { position: relative; width: 168px; height: 168px; border: 0; border-radius: 50%; background: var(--panel); display: grid; place-items: center; font-weight: 700; font-size: 22px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#gate-hold svg { position: absolute; inset: 0; transform: rotate(-90deg); }
#gate-hold circle { fill: none; stroke: var(--soft); stroke-width: 8; }
#gate-arc { stroke: var(--shape) !important; stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73; opacity: 0; }
.primary, .plain { min-height: 56px; padding: 8px 22px; border-radius: 16px; }
.primary { background: var(--shape); color: var(--on-shape); border: 0; font-weight: 600; }
.plain { background: transparent; border: 2px solid var(--soft); }

/* ---------- Grown-ups screen ---------- */
#settings, #editor, #picker { min-height: 100dvh; padding: max(16px, var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) 16px 48px; }
.sheet { max-width: 680px; margin: 0 auto; }
.head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 1; }
h1 { font-size: 28px; margin: 0; }
fieldset { border: 0; margin: 0 0 20px; padding: 16px; background: var(--panel); border-radius: 16px; min-width: 0; }
legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; font-weight: 700; }
legend + * { clear: both; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chips button { min-height: 48px; padding: 6px 16px; background: transparent; border: 2px solid var(--soft); border-radius: 12px; }
/* The grown-ups screen keeps strong colours whatever the child's background is. */
#settings, #gate, #editor, #picker { --shape: #2C5470; --on-shape: #fff; }
[data-palette="dark"] :is(#settings, #gate, #editor, #picker) { --shape: #9FC3D9; --on-shape: #1E2530; }
.chips button[aria-pressed="true"] { background: var(--shape); border-color: var(--shape); color: var(--on-shape); font-weight: 600; }
.chips button:disabled { opacity: .45; cursor: default; }
.pics button { width: 92px; padding: 8px 4px; font-size: 14px; line-height: 1.2; }
.pics svg { display: block; width: 52px; height: 52px; padding: 4px; margin: 0 auto 4px; background: #fff; border-radius: 10px; }
.sub { margin: 14px 0 8px; font-size: 15px; font-weight: 600; }
.hint { margin: 6px 0 10px; font-size: 15px; }
.row { display: flex; gap: 12px; align-items: center; margin: 6px 0 10px; }
.row input[type="text"] { flex: 1; min-width: 0; min-height: 48px; padding: 8px 12px; background: var(--bg); border: 2px solid var(--soft); border-radius: 12px; }
.file { display: inline-flex; align-items: center; cursor: pointer; min-height: 48px; }
.file:focus-within { outline: 3px solid var(--shape); outline-offset: 3px; }


/* ---------- Boards and the editor ---------- */
input[type="text"] { min-height: 48px; min-width: 0; padding: 8px 12px; background: var(--bg); border: 2px solid var(--soft); border-radius: 12px; }
#e-name, #link { width: 100%; }
#boards button { display: flex; width: 100%; align-items: center; gap: 12px; flex-wrap: wrap; text-align: left; min-height: 60px; padding: 8px 14px; margin-bottom: 8px; background: transparent; border: 2px solid var(--soft); border-radius: 14px; }
#boards button[aria-pressed="true"] { border: 4px solid var(--shape); padding: 6px 12px; }
#boards b { flex: 1 1 8em; font-weight: 600; overflow-wrap: anywhere; } #boards span { display: flex; gap: 3px; flex-wrap: wrap; } #boards span svg { width: 34px; height: 34px; background: #fff; border-radius: 8px; padding: 2px; }
details { margin: 8px 0 0; } summary { cursor: pointer; min-height: 48px; display: list-item; padding: 10px 0; font-weight: 600; }
.row { flex-wrap: wrap; }
.row input[type="text"] { flex: 1 1 8em; }
#e-steps { list-style: none; margin: 0 0 12px; padding: 0; }
#e-steps li { display: grid; grid-template-columns: 76px 1fr auto; gap: 10px; align-items: center; background: var(--panel); border-radius: 16px; padding: 10px; margin-bottom: 10px; }
#e-steps .pick { width: 76px; height: 76px; padding: 6px; background: #fff; border: 2px solid var(--soft); border-radius: 14px; } #e-steps .pick svg { display: block; width: 100%; height: 100%; }
#e-steps .fields { display: grid; gap: 6px; min-width: 0; } #e-steps input { width: 100%; }
#e-steps select { font: inherit; color: inherit; min-height: 44px; padding: 4px 8px; background: var(--bg); border: 2px solid var(--soft); border-radius: 12px; width: 100%; }
#e-steps .moves { display: grid; grid-template-columns: 48px; gap: 4px; } #e-steps .moves button { width: 48px; height: 44px; padding: 0; background: transparent; border: 2px solid var(--soft); border-radius: 12px; } #e-steps .moves svg { width: 24px; height: 24px; display: block; margin: auto; }
#e-steps button:disabled { opacity: .35; cursor: default; }
.wide { width: 100%; }
#shelves h2 { font-size: 18px; margin: 18px 0 8px; } #shelves .own { position: relative; display: inline-flex; flex-direction: column; gap: 4px; } #shelves .own button + button { min-height: 44px; }
#today-steps button[aria-pressed="true"] svg { outline: 3px solid var(--shape); }
#paper { display: none; }
@media (orientation: portrait) {
  #stage { --now: min(74vw, 30vh); --pair: min(64vw, 22vh); flex-direction: column; gap: 6px; }
  .arrow { transform: rotate(90deg); width: 30px; }
  .card.next { width: calc(var(--now) * .5); }
}
@media (max-height: 520px) { #child { gap: 4px; } .bar, #foot { min-height: 52px; } .tool.small { height: 52px; } .go { height: 56px; } .tool { width: 56px; height: 56px; } #strip { --m: min(48px, calc((100vw - 32px - 6px * (var(--n) - 1)) / var(--n)), 12vh); } #stage { --now: min(40vw, 34vh); --pair: min(30vw, 34vh); } }
/* Short and wide: the buttons sit beside the pictures. */
@media (max-height: 520px) and (orientation: landscape) {
  #child { display: grid; grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr) auto; }
  .bar, #strip { grid-column: 1 / -1; } #foot { flex-direction: column-reverse; } .go { width: 110px; height: 84px; }
}
/* Sized from the room the pictures really have: words, timer and arrow are the fixed part. */
@supports (width: 1cqh) {
  #stage { container-type: size; --now: min(52cqw, 100cqh - 84px); --pair: min(38cqw, 100cqh - 84px); }
  @media (orientation: portrait) { #stage { --now: min(80cqw, (100cqh - 170px) / 1.5); --pair: min(70cqw, (100cqh - 190px) / 2); } }
  @media (orientation: portrait) and (max-height: 660px) { #stage { flex-direction: row; --now: min(54cqw, 100cqh - 84px); --pair: min(40cqw, 100cqh - 84px); } .arrow { transform: none; } }
}
@media (max-width: 420px) { .tool.small span { display: none; } .card .word { margin-inline: -8px; } }
@media (forced-colors: active) { #strip .now .pic { outline: 3px solid; } }
/* ---------- Paper ---------- */
@media print {
  @page { margin: 12mm; }
  html, body { background: #fff; height: auto; }
  body > *:not(#paper) { display: none !important; }
  #paper { display: block; color: #000; }
  #paper h1 { font-size: 22pt; margin: 0 0 6mm; text-align: center; }
  #paper ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 5mm; }
  #paper li { border: 1.5pt solid #444; border-radius: 5mm; padding: 4mm; text-align: center; break-inside: avoid; font-weight: 700; font-size: var(--fs); }
  #paper svg { width: 100%; max-height: var(--max); display: block; margin: 0 auto 2mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #paper .n { font-weight: 400; font-size: 11pt; }
}
