/* QuantaPrism Blocks: our look. Colours match kids.quantaprism.com (KidsLibrary/internal/library/web/app.css). */
@font-face {
  font-family: "KidsSans";
  src: url("../fonts/NotoSans-SemiBold-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
:root {
  --paper: #fff6e6;
  --card: #ffffff;
  --ink: #2b2240;
  --ink-soft: #6a5f7d;
  --line: #f0dcb8;
  --accent: #e0563f;
  --accent-dark: #b83e2a;
  --sun: #ffd54a;
  --sky: #3f8fe0;
  --leaf: #2f9e6b;
  --leaf-dark: #1f7a50;
  --plum: #7a4fb5;
  --pink: #e5487f;
  --focus: #1d5fd1;
  --radius: 18px;
  --shadow: 0 4px 0 rgba(43, 34, 64, .12), 0 10px 24px rgba(43, 34, 64, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: KidsSans, "Noto Sans", system-ui, sans-serif;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn svg, .icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--card); color: var(--ink); font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 0 var(--line), 0 6px 14px rgba(43, 34, 64, .08);
  transition: transform .08s ease, box-shadow .08s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn.run { background: var(--leaf); color: #fff; box-shadow: 0 4px 0 var(--leaf-dark), 0 6px 14px rgba(47, 158, 107, .3); }
.btn.run:active { box-shadow: 0 1px 0 var(--leaf-dark); }
.btn.run.stop { background: var(--accent); box-shadow: 0 4px 0 var(--accent-dark); }
.btn.run svg { fill: #fff; stroke: #fff; stroke-width: 1.5; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: inline-grid; place-items: center;
  background: var(--card); box-shadow: 0 3px 0 var(--line); cursor: pointer; text-decoration: none; flex: none;
}
.link-btn { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; padding: 8px; }

/* ---------- home ---------- */
#home { max-width: 1100px; margin: 0 auto; padding: 12px 16px 40px; }
.home-top, .play-top { display: flex; align-items: center; gap: 10px; }
.home-top { justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.brand-icon { width: 40px; height: 40px; }
.top-tools { display: flex; gap: 8px; align-items: center; }
.lang { min-height: 44px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); padding: 0 12px; }
.hero { text-align: center; padding: 18px 0 8px; }
.hero h1 { font-size: clamp(26px, 6vw, 44px); margin: 6px 0 14px; line-height: 1.15; letter-spacing: -.5px; }
.hero-friends { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; }
.hero-friends img { width: clamp(54px, 14vw, 92px); height: auto; animation: bob 2.6s ease-in-out infinite; }
.hero-friends img:nth-child(2n) { animation-delay: -1.3s; }
.hero-friends img:nth-child(3n) { animation-delay: -.6s; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0 8px; }
.big-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-radius: 24px; text-decoration: none;
  color: #fff; box-shadow: var(--shadow); min-height: 130px; position: relative; overflow: hidden;
}
.big-card::after { content: ""; position: absolute; right: -30px; bottom: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255, 255, 255, .15); }
.puzzles-card { background: linear-gradient(135deg, #3f8fe0, #6a5ad8); }
.free-card { background: linear-gradient(135deg, #f08a24, #e5487f); }
.big-card-title { font-size: 26px; font-weight: 800; }
.big-card-text { font-size: 15px; line-height: 1.35; opacity: .95; max-width: 32ch; }
.big-card-progress { margin-top: auto; font-size: 14px; background: rgba(255, 255, 255, .22); border-radius: 999px; padding: 4px 12px; align-self: flex-start; }
.map-title { font-size: 22px; margin: 26px 4px 12px; }
.map { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.map a {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px 12px; text-decoration: none;
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow); text-align: center; position: relative; height: 100%;
  border: 3px solid transparent;
}
.map a:hover { border-color: var(--sun); }
.map .num {
  position: absolute; top: 8px; left: 10px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sun); font-weight: 800; font-size: 15px;
}
.map img { width: 74px; height: 74px; }
.map .name { font-weight: 800; font-size: 15px; line-height: 1.2; min-height: 2.4em; display: flex; align-items: center; }
.map .idea { font-size: 12px; color: var(--ink-soft); }
.map .stars { font-size: 20px; letter-spacing: 1px; }
.map li.locked a { opacity: .55; filter: grayscale(.7); }
.map li.locked .num::after { content: ""; }
.stars .on { color: #ffb300; }
.stars .off { color: #e6d7bb; }
.home-foot { margin-top: 30px; text-align: center; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }

/* ---------- play ---------- */
#play { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.play-top { padding: 8px 12px; background: var(--sun); box-shadow: 0 3px 0 rgba(43, 34, 64, .08); z-index: 2; }
.play-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.play-level { font-size: 13px; color: #6b5200; font-weight: 800; }
.play-name { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-stars { font-size: 22px; white-space: nowrap; }
.play-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.left { display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 6px; }
.right { flex: 1; min-height: 0; position: relative; border-top: 3px solid var(--line); }
.blockly-host { position: absolute; inset: 0; }
.goal-card { display: flex; gap: 10px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 8px 12px 8px 8px; box-shadow: 0 3px 0 var(--line); }
.goal-face { width: 52px; height: 52px; flex: none; }
.goal-text { min-width: 0; }
.goal-main { margin: 0; font-size: 15px; font-weight: 800; line-height: 1.3; }
.goal-sub { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.idea-chip { display: inline-block; background: #e8f0ff; color: #2a5bb3; border-radius: 999px; padding: 1px 8px; font-weight: 800; margin-left: 2px; }
.idea-chip:empty { display: none; }
.picker { display: flex; gap: 6px; overflow-x: auto; padding: 2px; }
.picker button { border: 3px solid transparent; background: var(--card); border-radius: 50%; padding: 0; width: 52px; height: 52px; flex: none; cursor: pointer; box-shadow: 0 3px 0 var(--line); }
.picker button img { width: 100%; height: 100%; display: block; }
.picker button[aria-pressed="true"] { border-color: var(--accent); transform: scale(1.06); }
.stage-wrap { position: relative; height: clamp(150px, 29dvh, 290px); display: flex; align-items: center; justify-content: center; }
#stage { display: block; border-radius: 16px; box-shadow: var(--shadow); touch-action: manipulation; }
.toast {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); max-width: calc(100% - 16px); width: max-content;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 16px; font-size: 15px; line-height: 1.35; text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .25); animation: pop .25s ease-out; z-index: 3;
}
.toast.hint { background: #fff3c4; color: var(--ink); border: 3px solid var(--sun); }
@keyframes pop { from { transform: translateX(-50%) scale(.8); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.controls { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 8px; }
.controls .btn { padding: 0 8px; font-size: 15px; }
.count { margin: 0; font-size: 12px; color: var(--ink-soft); text-align: center; min-height: 1em; }

/* Laptop: stage on the left, blocks on the right. */
@media (min-width: 860px) {
  .play-body { flex-direction: row; }
  .left { width: min(44vw, 520px); flex: none; padding: 14px 16px; gap: 12px; overflow-y: auto; }
  .right { border-top: 0; border-left: 3px solid var(--line); }
  .stage-wrap { flex: 1; height: auto; min-height: 220px; max-height: 460px; }
  .goal-face { width: 64px; height: 64px; }
  .goal-main { font-size: 17px; }
  .controls .btn { font-size: 16px; }
  .count { font-size: 13px; }
}
/* Very small phones: smaller words on the buttons. */
@media (max-width: 370px) {
  .controls .btn span { font-size: 13px; }
  .controls .btn svg { width: 18px; height: 18px; }
}

/* ---------- dialogs ---------- */
.overlay { position: fixed; inset: 0; background: rgba(43, 34, 64, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.dialog { background: var(--card); border-radius: 26px; padding: 22px 20px 18px; width: min(460px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); text-align: center; animation: rise .3s cubic-bezier(.2, 1.4, .5, 1); }
@keyframes rise { from { transform: translateY(30px) scale(.9); opacity: 0; } }
.dialog h2 { margin: 6px 0; font-size: 28px; }
.dialog p { margin: 6px 0; line-height: 1.4; }
.dialog-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.dialog-buttons .btn { flex: 1; min-width: 130px; }
/* The win box leaves the stage in view so the party can be seen: at the bottom on phones,
   over the blocks on laptops. */
.win-overlay { background: rgba(43, 34, 64, .25); align-items: end; }
.win-overlay .dialog { margin-bottom: 8px; }
@media (min-width: 860px) {
  .win-overlay { align-items: center; justify-items: end; padding-right: max(16px, calc((100vw - min(44vw, 520px)) / 2 - 230px)); }
}
.win-face { width: 96px; height: 96px; margin-top: -60px; animation: bob 1.4s ease-in-out infinite; }
.win-stars { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.win-stars span { font-size: 54px; line-height: 1; color: #e6d7bb; transform: scale(.3); opacity: 0; animation: star .45s cubic-bezier(.2, 1.6, .5, 1) forwards; }
.win-stars span.on { color: #ffb300; text-shadow: 0 3px 0 #d98a00; }
.win-stars span:nth-child(2) { animation-delay: .25s; font-size: 66px; margin-top: -10px; }
.win-stars span:nth-child(3) { animation-delay: .5s; }
@keyframes star { to { transform: scale(1); opacity: 1; } }
.win-more { color: var(--ink-soft); font-size: 14px; }
.dialog.code { width: min(640px, 100%); text-align: left; }
.code-about { color: var(--ink-soft); font-size: 14px; }
.tabs { display: flex; gap: 6px; margin: 10px 0 0; }
.tab { border: 0; border-radius: 12px 12px 0 0; padding: 10px 16px; background: #f3e6cc; cursor: pointer; font-weight: 800; min-height: 44px; }
.tab[aria-selected="true"] { background: #2b2240; color: #fff; }
.code-text {
  margin: 0; background: #2b2240; color: #fdf6e3; border-radius: 0 14px 14px 14px; padding: 14px 16px; min-height: 140px; max-height: 50vh;
  overflow: auto; font: 600 14px/1.55 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; white-space: pre;
}

/* Blockly: big friendly blocks */
.blocklyToolboxDiv, .blocklyToolbox { background: #fff0d6 !important; }
.blocklyTreeRow, .blocklyToolboxCategory { border-radius: 12px; margin: 4px 6px !important; height: auto !important; padding: 8px 6px !important; }
.blocklyTreeLabel, .blocklyToolboxCategoryLabel { font-family: KidsSans, "Noto Sans", system-ui, sans-serif !important; font-weight: 800 !important; font-size: 15px !important; }
.blocklyText { font-family: KidsSans, "Noto Sans", system-ui, sans-serif !important; }
.blocklyMainBackground { stroke: none !important; }

/* ---------- free play: examples, lessons ---------- */
.free-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.free-tools .btn { min-height: 44px; font-size: 15px; color: #fff; }
.free-tools .ex-btn { background: linear-gradient(135deg, #f08a24, #e5487f); box-shadow: 0 4px 0 #bf2d61; }
.free-tools .learn-btn { background: linear-gradient(135deg, #3f8fe0, #6a5ad8); box-shadow: 0 4px 0 #4a3fae; }
.free-tools .btn:active { box-shadow: 0 1px 0 rgba(43, 34, 64, .3); }
.free-tools .ex-btn svg { fill: #fff; stroke: #fff; stroke-width: 1.5; }
.free-tools .learn-btn svg { stroke: #fff; }
.dialog.pick { width: min(560px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.pick-about { color: var(--ink-soft); font-size: 15px; }
.pick-list { display: grid; grid-template-columns: 1fr; gap: 10px; overflow-y: auto; padding: 4px 2px 6px; margin-top: 6px; min-height: 0; }
@media (min-width: 560px) { .pick-list { grid-template-columns: 1fr 1fr; } }
.pick-card {
  display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer; min-height: 72px;
  border: 3px solid var(--line); background: #fffaf0; border-radius: 20px; padding: 8px 12px 8px 8px;
  box-shadow: 0 3px 0 var(--line); position: relative; touch-action: manipulation;
}
.pick-card:hover, .pick-card:focus-visible { border-color: var(--sun); background: #fff3c4; }
.pick-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.pick-card img { width: 56px; height: 56px; flex: none; object-fit: contain; }
.pick-words { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick-title { font-weight: 800; font-size: 16px; line-height: 1.2; }
.pick-sub { font-size: 13px; color: var(--ink-soft); line-height: 1.3; }
.pick-done { align-self: flex-start; margin-top: 2px; background: var(--leaf); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 800; }

.tut-card {
  display: flex; gap: 10px; align-items: center; background: #fff3c4; border: 3px solid var(--sun); border-radius: var(--radius);
  padding: 6px 6px 6px 8px; box-shadow: 0 3px 0 #e8c98f; animation: pop-in .3s ease-out;
}
.tut-card.good { background: #e2f6ea; border-color: var(--leaf); box-shadow: 0 3px 0 #a9dcbf; }
@keyframes pop-in { from { transform: scale(.94); opacity: 0; } }
.tut-face { width: 48px; height: 48px; flex: none; animation: bob 2.4s ease-in-out infinite; }
.tut-text { flex: 1; min-width: 0; }
.tut-step { margin: 0; font-size: 12px; color: #6b5200; font-weight: 800; }
.tut-card.good .tut-step { color: var(--leaf-dark); font-size: 15px; }
.tut-main { margin: 2px 0 4px; font-size: 15px; font-weight: 800; line-height: 1.3; }
.tut-dots { display: flex; gap: 5px; }
.tut-dots span { width: 10px; height: 10px; border-radius: 50%; background: #e8d6ae; }
.tut-dots span.now { background: var(--accent); transform: scale(1.25); }
.tut-dots span.done { background: var(--leaf); }
.tut-close { width: 40px; height: 40px; align-self: flex-start; }
.tut-close svg { width: 18px; height: 18px; }
@media (min-width: 860px) { .tut-face { width: 60px; height: 60px; } .tut-main { font-size: 17px; } }

/* The block to use glows; a bouncing arrow points at it; Run pulses when it is time to press it. */
.qp-glow > .blocklyPath { stroke: #ffb300 !important; stroke-width: 5px !important; animation: glow .8s ease-in-out infinite alternate; }
@keyframes glow { from { stroke-opacity: .35; } to { stroke-opacity: 1; } }
.tut-pointer { position: fixed; z-index: 40; width: 40px; height: 40px; pointer-events: none; animation: nudge .7s ease-in-out infinite alternate; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.tut-pointer svg { width: 100%; height: 100%; fill: var(--accent); stroke: #fff; stroke-width: 2.5; stroke-linejoin: round; }
@keyframes nudge { from { transform: translateX(0); } to { transform: translateX(10px); } }
.btn.run.tut-pulse { animation: pulse 1s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 4px 0 var(--leaf-dark), 0 0 0 0 rgba(255, 179, 0, .9); } 100% { box-shadow: 0 4px 0 var(--leaf-dark), 0 0 0 16px rgba(255, 179, 0, 0); } }

/* Free play block list: a coloured heading above each group of blocks. */
.qp-label .blocklyFlyoutLabelText { font-family: KidsSans, "Noto Sans", system-ui, sans-serif !important; font-weight: 800 !important; font-size: 15px !important; }
.qp-label-motion .blocklyFlyoutLabelText { fill: #2a6db3 !important; }
.qp-label-talk .blocklyFlyoutLabelText { fill: #6a3fa6 !important; }
.qp-label-control .blocklyFlyoutLabelText { fill: #c76a10 !important; }
.qp-label-fun .blocklyFlyoutLabelText { fill: #bf2d61 !important; }

/* ---------- "Page looks old? Get the newest version" (js/fresh.js) ---------- */
.fresh-link { background: none; border: 0; padding: 8px 0; margin: 0; font: inherit; font-size: 15px; color: var(--ink-soft); text-decoration: underline; cursor: pointer; min-height: 44px; }
.fresh-link:hover { color: var(--ink); }
dialog.fresh { width: min(580px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; border: 0; border-radius: 26px; padding: 22px 20px 18px; background: var(--card); color: var(--ink); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); font: inherit; line-height: 1.45; }
dialog.fresh::backdrop { background: rgba(43, 34, 64, .45); }
.fresh h2 { margin: 0 40px 8px 0; font-size: 24px; line-height: 1.2; }
.fresh h3 { margin: 18px 0 6px; font-size: 19px; }
.fresh h4 { margin: 10px 0 2px; font-size: 16px; color: var(--plum); }
.fresh p { margin: 6px 0; }
.fresh ol { margin: 2px 0 6px; padding-left: 24px; }
.fresh li { margin: 3px 0; }
.fresh-x { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--line); background: var(--card); color: var(--ink); font-size: 26px; line-height: 1; cursor: pointer; }
.fresh-go { display: flex; width: 100%; align-items: center; justify-content: center; min-height: 60px; margin: 14px 0 6px; padding: 10px 22px; border: 0; border-radius: 999px; background: var(--leaf); color: #fff; font: inherit; font-weight: 800; font-size: 21px; cursor: pointer; box-shadow: 0 4px 0 var(--leaf-dark); }
.fresh-go:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--leaf-dark); }
.fresh-go[disabled] { opacity: .6; cursor: wait; }
.fresh-bar { height: 12px; border-radius: 999px; background: var(--paper-2, #ffeccc); overflow: hidden; margin: 8px 0 2px; }
.fresh-bar i { display: block; height: 100%; width: 0; background: var(--sun); }
.fresh-bar[hidden] { display: none; }
.fresh-status { min-height: 1.45em; font-weight: 800; }
.fresh-status.ok { color: var(--ok-ink, #1f6e47); }
.fresh-status.bad { color: var(--accent-dark); }
.fresh-hand { border-top: 3px solid var(--line); margin-top: 12px; }
.fresh-group { background: var(--paper); border-radius: 16px; padding: 4px 14px 6px; margin: 8px 0; }
.fresh-note { font-size: 15px; color: var(--ink-soft); }
.fresh-note.warn { background: var(--try-bg, #fff0d6); color: var(--try-ink, #8a5a00); border-radius: 12px; padding: 8px 12px; }
.fresh-close { display: block; margin: 12px auto 0; min-height: 44px; padding: 6px 22px; border-radius: 999px; border: 3px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 800; font-size: 16px; cursor: pointer; }
.fresh-toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); background: var(--ok-bg, #e2f6ea); color: var(--ok-ink, #1f6e47); border: 3px solid var(--leaf); border-radius: 18px; padding: 10px 18px; font-weight: 800; z-index: 60; box-shadow: var(--shadow); transition: opacity .5s; text-align: center; }
.fresh-toast.gone { opacity: 0; }
