/* =========================================================
   THINK INDUSTRIES — progressive tier themes
   ---------------------------------------------------------
   <body class="themed tier-1">  Robot Playground   ages 6–7
   <body class="themed tier-2">  Inventor's Workshop ages 8–9
   <body class="themed tier-3">  Maker Lab          ages 10–11
   <body class="themed tier-4">  Engineering HQ     ages 12–13
   (no "themed" class)           Hacker Terminal    ages 14+  (the default look)
   Each tier only sets the colour/size tokens below; the shared
   rules further down apply them to every component.
   ========================================================= */

body.tier-1 {
    --t-bg: linear-gradient(180deg, #bfe9ff 0%, #e8f7ff 45%, #fff6d8 100%);
    --t-text: #23324a; --t-muted: #5b6b85; --t-head: #ff6b00;
    --t-accent: #ff7a00; --t-accent2: #1fa7e8; --t-ok: #2fb84f; --t-warn: #ff9f1c; --t-bad: #e5484d;
    --t-panel: #ffffff; --t-panel2: #fff8e8; --t-line: #ffd38a;
    --t-code-bg: #fffdf5; --t-code-text: #23324a; --t-code-line: #f1e3c2;
    --t-board: #e9f8ff; --t-floor: #ffffff; --t-wall: #8ecae6;
    --t-font: 'Fredoka', 'Comic Sans MS', 'Segoe UI', sans-serif; --t-head-font: 'Fredoka', 'Segoe UI', sans-serif;
    --t-size: 1.2rem; --t-radius: 24px; --t-code-size: 19px; --t-btn-pad: 14px 22px;
}
body.tier-2 {
    --t-bg: #fdf6ec;
    --t-text: #2d2a32; --t-muted: #6f6874; --t-head: #e4572e;
    --t-accent: #00a6a6; --t-accent2: #e4572e; --t-ok: #1f9e5a; --t-warn: #f29e1d; --t-bad: #d64545;
    --t-panel: #ffffff; --t-panel2: #fff4e3; --t-line: #f2d4b0;
    --t-code-bg: #fffaf2; --t-code-text: #2d2a32; --t-code-line: #efe1cc;
    --t-board: #f3fbfb; --t-floor: #ffffff; --t-wall: #e8b98a;
    --t-font: 'Nunito', 'Segoe UI', sans-serif; --t-head-font: 'Fredoka', 'Segoe UI', sans-serif;
    --t-size: 1.1rem; --t-radius: 18px; --t-code-size: 17px; --t-btn-pad: 11px 18px;
}
body.tier-3 {
    --t-bg: #eaf2ff linear-gradient(rgba(30, 107, 214, .07) 1px, transparent 1px) 0 0 / 22px 22px;
    --t-text: #142a4c; --t-muted: #50607a; --t-head: #1e6bd6;
    --t-accent: #1e6bd6; --t-accent2: #f4a300; --t-ok: #12915a; --t-warn: #e08a00; --t-bad: #d43d3d;
    --t-panel: #ffffff; --t-panel2: #f2f7ff; --t-line: #c4d8f5;
    --t-code-bg: #0d1b2a; --t-code-text: #e3edf9; --t-code-line: #1e3350;
    --t-board: #0f2440; --t-floor: #1b3557; --t-wall: #6b8bb5;
    --t-font: 'Nunito', 'Segoe UI', sans-serif; --t-head-font: 'Nunito', 'Segoe UI', sans-serif;
    --t-size: 1.02rem; --t-radius: 14px; --t-code-size: 15px; --t-btn-pad: 9px 16px;
}
body.tier-4 {
    --t-bg: #0b1220;
    --t-text: #dbe4f0; --t-muted: #8a99b2; --t-head: #38d6f0;
    --t-accent: #22d3ee; --t-accent2: #a78bfa; --t-ok: #34d399; --t-warn: #fbbf24; --t-bad: #f87171;
    --t-panel: #111a2e; --t-panel2: #16213a; --t-line: #26344f;
    --t-code-bg: #0a0f1c; --t-code-text: #e2e8f0; --t-code-line: #1c2740;
    --t-board: #0d1526; --t-floor: #1a2540; --t-wall: #3b4a6b;
    --t-font: 'Segoe UI', system-ui, sans-serif; --t-head-font: 'Segoe UI', system-ui, sans-serif;
    --t-size: 1rem; --t-radius: 10px; --t-code-size: 14px; --t-btn-pad: 8px 14px;
}

/* ---------- Shared themed rules ---------- */
body.themed {
    background: var(--t-bg); background-attachment: fixed; color: var(--t-text);
    font-family: var(--t-font); font-size: var(--t-size);
    --accent-green: var(--t-accent); --accent-blue: var(--t-accent2); --border: var(--t-line);
    --ti-green: var(--t-ok); --ti-blue: var(--t-accent2); --ti-amber: var(--t-warn); --ti-red: var(--t-bad); --ti-line: var(--t-line);
}
body.themed::before { display: none; }
body.themed a { color: var(--t-accent2); }
body.themed .nav-header { background: var(--t-panel); border-bottom: 3px solid var(--t-line); }
body.themed .back-link { color: var(--t-accent2); font-family: var(--t-head-font); }
body.themed .nav-right, body.themed .nav-right a { font-family: var(--t-head-font); color: var(--t-accent); }
body.themed .briefing-box { background: var(--t-panel); border: 2px solid var(--t-line); border-radius: var(--t-radius); box-shadow: 0 8px 30px rgba(0, 0, 0, .08); }
body.themed h1 {
    color: var(--t-head); font-family: var(--t-head-font); text-transform: none; letter-spacing: 0;
    border-left: 0; padding-left: 0; font-size: clamp(1.7rem, 5vw, 2.6rem);
}
body.themed .subtitle { color: var(--t-muted); }
body.themed .tier-badge {
    display: inline-block; font-family: var(--t-head-font); font-size: 0.85rem; padding: 4px 12px; border-radius: 99px;
    background: var(--t-accent); color: #fff; margin-bottom: 10px;
}
body.themed .lesson { border-top: 2px dashed var(--t-line); }
body.themed .lesson > h2 { color: var(--t-text); font-family: var(--t-head-font); }
body.themed .lesson > h2 .num {
    display: inline-block; min-width: 2em; text-align: center; color: #fff; background: var(--t-accent);
    border-radius: 99px; padding: 0 10px; font-family: var(--t-head-font);
}
body.themed h3 { color: var(--t-text); }
body.themed code { background: var(--t-panel2); color: var(--t-accent2); border: 1px solid var(--t-line); }
body.themed pre.ti-code { background: var(--t-code-bg); color: var(--t-code-text); border-color: var(--t-code-line); border-radius: calc(var(--t-radius) / 2); }
body.themed pre.ti-code .c { color: #7a9a6a; }
body.themed .step-card { background: var(--t-panel2); border-left-color: var(--t-accent2); }
body.themed table.ref th { color: var(--t-accent2); }
body.themed table.ref th, body.themed table.ref td { border-bottom-color: var(--t-line); }
body.themed .ti-compare h4 { color: var(--t-accent2); }
body.themed .ti-callout { background: var(--t-panel2); border: 2px solid var(--t-accent2); border-radius: var(--t-radius); color: var(--t-text); }
body.themed .ti-callout strong { color: var(--t-accent2); }
body.themed .ti-callout.warn { border-color: var(--t-warn); }
body.themed .ti-callout.warn strong { color: var(--t-warn); }
body.themed .ti-lesson-map a { border: 2px solid var(--t-line); color: var(--t-text); background: var(--t-panel2); font-family: var(--t-head-font); }
body.themed .ti-lesson-map a.done { border-color: var(--t-ok); color: var(--t-ok); }
body.themed .status-footer { color: var(--t-muted); }

/* Buttons */
body.themed .ti-btn {
    border-radius: calc(var(--t-radius) / 1.6); padding: var(--t-btn-pad); font-family: var(--t-head-font); text-transform: none; letter-spacing: 0;
    border: 2px solid var(--t-accent); color: var(--t-accent); background: var(--t-panel);
}
body.themed .ti-btn:hover { background: var(--t-accent); color: #fff; box-shadow: none; }
body.themed .ti-btn.blue { border-color: var(--t-accent2); color: var(--t-accent2); }
body.themed .ti-btn.blue:hover { background: var(--t-accent2); color: #fff; }
body.themed .ti-btn.ghost { border-color: var(--t-line); color: var(--t-muted); }
body.themed .ti-btn.ghost:hover { background: var(--t-panel2); color: var(--t-text); }
body.themed .ti-run { background: var(--t-ok) !important; border-color: var(--t-ok) !important; color: #fff !important; }
body.themed .ti-check { background: var(--t-panel) !important; border-color: var(--t-accent2) !important; color: var(--t-accent2) !important; }
body.themed .ti-check:hover { background: var(--t-accent2) !important; color: #fff !important; }

/* Code lab */
body.themed .ti-lab { background: var(--t-panel); border: 2px solid var(--t-line); border-radius: var(--t-radius); }
body.themed .ti-lab-head, body.themed .kind-example .ti-lab-head { background: var(--t-panel2); border-bottom: 2px solid var(--t-line); }
body.themed .ti-lab-title { color: var(--t-text); font-family: var(--t-head-font); font-size: 1.1em; }
body.themed .ti-kind { background: var(--t-accent); color: #fff; font-family: var(--t-head-font); border-radius: 99px; padding: 2px 10px; font-size: 0.75rem; }
body.themed .kind-example .ti-kind { background: var(--t-accent2); }
body.themed .ti-passed { color: var(--t-ok); border-color: var(--t-ok); border-radius: 99px; }
body.themed .ti-langs { border-color: var(--t-line); border-radius: 99px; }
body.themed .ti-langs button { color: var(--t-muted); }
body.themed .ti-langs button + button { border-left-color: var(--t-line); }
body.themed .ti-langs button.active { background: var(--t-accent2); color: #fff; }
body.themed .ti-lab > .ti-task { color: var(--t-text); }
body.themed .ti-task code, body.themed .ti-hint-list code, body.themed .ti-verdict code { background: var(--t-panel2); color: var(--t-accent2); }
body.themed .ti-code-col { border-right-color: var(--t-line); }
body.themed .ti-toolbar { background: var(--t-panel2); border-top-color: var(--t-line); }
body.themed .ti-status { color: var(--t-warn); }

body.themed .ti-editor .CodeMirror { font-size: var(--t-code-size); }
body.themed .cm-s-ti.CodeMirror, body.themed .ti-textarea { background: var(--t-code-bg); color: var(--t-code-text); }
body.themed .cm-s-ti .CodeMirror-gutters { background: var(--t-code-bg); border-right-color: var(--t-code-line); }
body.themed .cm-s-ti .CodeMirror-cursor { border-left-color: var(--t-accent); }
body.tier-1 .cm-s-ti .cm-keyword, body.tier-2 .cm-s-ti .cm-keyword { color: #c2185b; }
body.tier-1 .cm-s-ti .cm-def, body.tier-2 .cm-s-ti .cm-def { color: #2e7d32; }
body.tier-1 .cm-s-ti .cm-variable, body.tier-2 .cm-s-ti .cm-variable { color: #23324a; }
body.tier-1 .cm-s-ti .cm-variable-2, body.tier-2 .cm-s-ti .cm-variable-2,
body.tier-1 .cm-s-ti .cm-variable-3, body.tier-2 .cm-s-ti .cm-variable-3,
body.tier-1 .cm-s-ti .cm-type, body.tier-2 .cm-s-ti .cm-type,
body.tier-1 .cm-s-ti .cm-builtin, body.tier-2 .cm-s-ti .cm-builtin { color: #1565c0; }
body.tier-1 .cm-s-ti .cm-number, body.tier-2 .cm-s-ti .cm-number { color: #7b1fa2; }
body.tier-1 .cm-s-ti .cm-string, body.tier-2 .cm-s-ti .cm-string { color: #b45309; }
body.tier-1 .cm-s-ti .cm-comment, body.tier-2 .cm-s-ti .cm-comment { color: #6b8f5a; }
body.tier-1 .cm-s-ti .cm-property, body.tier-2 .cm-s-ti .cm-property { color: #0277bd; }
body.tier-1 .cm-s-ti .cm-meta, body.tier-2 .cm-s-ti .cm-meta { color: #c2410c; }
body.tier-1 .cm-s-ti .cm-operator, body.tier-2 .cm-s-ti .cm-operator,
body.tier-1 .cm-s-ti .cm-atom, body.tier-2 .cm-s-ti .cm-atom { color: #c2185b; }
body.tier-1 .cm-s-ti .CodeMirror-linenumber, body.tier-2 .cm-s-ti .CodeMirror-linenumber { color: #b9a98a; }

body.themed .ti-board { background: var(--t-board); border-bottom-color: var(--t-line); }
body.themed .ti-part { background: var(--t-panel); border: 2px solid var(--t-line); border-radius: calc(var(--t-radius) / 1.6); }
body.themed .ti-part-label, body.themed .ti-part-label b { color: var(--t-text); }
body.themed .ti-part-label span { color: var(--t-muted); }
body.tier-3 .ti-part, body.tier-4 .ti-part { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); }
body.tier-3 .ti-part-label, body.tier-3 .ti-part-label b { color: #e3edf9; }
body.themed .ti-grid { background: var(--t-wall); border-radius: calc(var(--t-radius) / 1.6); }
body.themed .ti-grid .floor { background: var(--t-floor); }
body.themed .ti-grid .wall { background: var(--t-wall); }
body.themed .ti-bot .dir { border-top-color: var(--t-accent); }

body.themed .ti-serial-head { background: var(--t-panel2); color: var(--t-accent2); border-bottom-color: var(--t-line); font-family: var(--t-head-font); }
body.themed .ti-serial { background: var(--t-code-bg); color: var(--t-code-text); font-size: calc(var(--t-code-size) - 2px); }
body.themed .ti-verdict.pass { background: color-mix(in srgb, var(--t-ok) 14%, var(--t-panel)); color: var(--t-text); }
body.themed .ti-verdict.pass b { color: var(--t-ok); }
body.themed .ti-verdict.fail { background: color-mix(in srgb, var(--t-warn) 14%, var(--t-panel)); color: var(--t-text); }
body.themed .ti-verdict.fail b { color: var(--t-warn); }
body.themed .ti-hint-list { background: var(--t-panel2); color: var(--t-text); border-top-color: var(--t-line); }
body.themed .ti-muted { color: var(--t-muted); }

/* Quiz */
body.themed .ti-section-label { color: var(--t-accent); font-family: var(--t-head-font); }
body.themed .ti-quiz { background: var(--t-panel2); border: 2px solid var(--t-line); border-radius: var(--t-radius); }
body.themed .ti-quiz-head { color: var(--t-accent); font-family: var(--t-head-font); }
body.themed .ti-q-text { color: var(--t-text); }
body.themed .ti-opt { border: 2px solid var(--t-line); background: var(--t-panel); border-radius: calc(var(--t-radius) / 1.6); }
body.themed .ti-opt:hover { border-color: var(--t-accent2); }
body.themed .ti-explain { color: var(--t-muted); }
body.themed .ti-q-text code, body.themed .ti-opt code { background: var(--t-panel2); color: var(--t-accent2); }
body.themed .ti-complete-note { color: var(--t-muted); }

/* ---------- Tier 1 & 2: fewer things on screen ---------- */
body.tier-1 .ti-replay, body.tier-1 .ti-clock,
body.tier-2 .ti-replay { display: none; }
body.tier-1 .ti-langs { display: none; }          /* youngest kids: one language at a time, chosen by the teacher/parent */
@media (min-width: 901px) { body.tier-1 .ti-lab-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); } }
body.tier-1 .ti-serial { min-height: 60px; }
body.tier-1 .ti-toolbar .ti-btn { font-size: 1.05rem; }
body.tier-1 .ti-run { font-size: 1.2rem !important; padding: 14px 28px !important; }
body.tier-1 .ti-lab-title { font-size: 1.35rem; }
body.tier-1 .ti-lab > .ti-task { font-size: 1.25rem; }
body.tier-1 .ti-grid { max-width: 520px; }
body.tier-1 .ti-grid .cell { font-size: clamp(1.1rem, 4vw, 1.9rem); }
body.tier-1 .ti-bot { font-size: clamp(1.2rem, 4.4vw, 2.1rem); }
body.tier-1 .ti-bulb { width: 54px; height: 54px; }
body.tier-1 .ti-part { max-width: 180px; }

/* ---------- Command buttons (big code blocks for young kids) ---------- */
.ti-blocks {
    display: flex; flex-wrap: wrap; gap: 10px; padding: 12px; align-items: stretch;
    border-bottom: 2px solid var(--t-line, rgba(255, 255, 255, .1)); background: var(--t-panel2, rgba(255, 255, 255, .03));
}
.ti-blocks-label { width: 100%; font-family: var(--t-head-font, monospace); color: var(--t-muted, #aaa); font-size: 0.9rem; }
.ti-block {
    --bc: var(--t-accent2, #00d4ff);
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-width: 92px; padding: 10px 12px; border-radius: 16px; cursor: pointer;
    background: var(--bc); color: #fff; border: 0; box-shadow: 0 5px 0 color-mix(in srgb, var(--bc) 60%, #000);
    font-family: var(--t-head-font, 'Segoe UI', sans-serif); font-size: 1rem; font-weight: 600;
    transition: transform .06s, box-shadow .06s;
}
.ti-block .ico { font-size: 1.9rem; line-height: 1; }
.ti-block:active { transform: translateY(4px); box-shadow: 0 1px 0 color-mix(in srgb, var(--bc) 60%, #000); }
.ti-block.small { --bc: #8b95a7; min-width: 70px; font-size: 0.85rem; }
.ti-block.small .ico { font-size: 1.3rem; }
.ti-block:focus-visible { outline: 3px solid var(--t-accent, #ff0); outline-offset: 2px; }
.ti-flash { animation: ti-flash .6s; }
@keyframes ti-flash { from { background: color-mix(in srgb, var(--t-accent, #ff0) 35%, transparent); } }

/* ---------- Homepage tier cards ---------- */
.card.tier-card { overflow: hidden; }
/* The landing page keeps one uniform look; each tier's own theme starts on its lesson page. */
.card .age { display: inline-block; font-size: 0.75rem; padding: 2px 10px; border-radius: 99px; margin-left: 8px; vertical-align: middle;
    color: var(--accent-green, #00ff41); border: 1px solid var(--accent-green, #00ff41); background: rgba(0, 255, 65, .08); font-weight: 700; text-transform: none; }
.card .theme-name { display: block; font-size: 0.8rem; opacity: .75; margin: -8px 0 10px; font-style: italic; }

/* ---------- Robot grid: stars to collect ---------- */
.ti-grid .cell.star { transition: opacity .3s, transform .3s; }
.ti-grid .cell.star.got { opacity: .15; transform: scale(.5); }

/* ---------- Step-by-step pages (ti-steps.js) ---------- */
.ti-stepper { margin: 18px 0 8px; scroll-margin-top: 10px; }
.ti-stepper-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; counter-reset: none; }
.ti-stepper-list li { margin: 0; position: relative; }
.ti-stepper-btn {
    width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px 12px; cursor: pointer;
    background: var(--t-panel, #111); color: var(--t-text, #eee); border: 3px solid var(--t-line, #333); border-radius: var(--t-radius, 12px);
    font-family: var(--t-head-font, inherit); font-size: 1rem; transition: transform .1s, border-color .2s, box-shadow .2s;
}
.ti-stepper-btn:hover { transform: translateY(-2px); border-color: var(--t-accent2, #0af); }
.ti-stepper-btn:focus-visible { outline: 3px solid var(--t-accent, #ff0); outline-offset: 2px; }
.ti-stepper-ico { font-size: 2.2rem; line-height: 1.1; }
.ti-stepper-num { font-size: .8rem; color: var(--t-muted, #999); text-transform: uppercase; letter-spacing: .04em; }
.ti-stepper-name { font-weight: 600; font-size: 1.05rem; text-align: center; line-height: 1.2; }
.ti-stepper-stars { font-size: .85rem; color: var(--t-muted, #999); min-height: 1.2em; margin-top: 4px; }
.ti-stepper-btn.current { border-color: var(--t-accent, #f80); box-shadow: 0 6px 0 color-mix(in srgb, var(--t-accent, #f80) 45%, transparent); }
.ti-stepper-btn.done { background: color-mix(in srgb, var(--t-ok, #2b5) 12%, var(--t-panel, #fff)); border-color: var(--t-ok, #2b5); }
.ti-stepper-btn.done .ti-stepper-stars { color: var(--t-ok, #2b5); font-weight: 700; }
.ti-stepper-btn.done.current { border-color: var(--t-accent, #f80); }
.ti-stepper-btn.locked { opacity: .55; filter: grayscale(.7); }
.ti-stepper-adult { text-align: right; margin-top: 6px; }
.ti-link-btn { background: none; border: 0; padding: 2px 4px; color: var(--t-muted, #999); font: inherit; font-size: .78rem; text-decoration: underline; cursor: pointer; }
.ti-step[hidden], .ti-step-lock[hidden] { display: none !important; }
.ti-step-lock { text-align: center; padding: 40px 16px; margin: 18px 0; border: 3px dashed var(--t-line, #444); border-radius: var(--t-radius, 12px); background: var(--t-panel2, #222); }
.ti-step-lock-ico { font-size: 3.4rem; }
.ti-step-lock h2 { font-family: var(--t-head-font, inherit); margin: 6px 0; color: var(--t-text, #eee); }
.ti-step-head { display: flex; align-items: center; gap: 14px; margin: 26px 0 6px; }
.ti-step-head .big-ico { font-size: 3rem; line-height: 1; }
.ti-step-head h2 { margin: 0; font-family: var(--t-head-font, inherit); color: var(--t-head, #fff); font-size: clamp(1.5rem, 4.5vw, 2.1rem); }
.ti-step-head p { margin: 2px 0 0; color: var(--t-muted, #aaa); }
.ti-step-foot { margin: 28px 0 8px; padding: 18px; border-radius: var(--t-radius, 12px); border: 3px dashed var(--t-line, #444); background: var(--t-panel2, #222); text-align: center; }
.ti-step-foot.ready { border-style: solid; border-color: var(--t-ok, #2b5); background: color-mix(in srgb, var(--t-ok, #2b5) 10%, var(--t-panel, #fff)); }
.ti-step-foot-msg { font-family: var(--t-head-font, inherit); font-size: 1.2rem; margin-bottom: 8px; }
.ti-step-todo { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ti-step-todo li { background: var(--t-panel, #111); border: 2px solid var(--t-line, #333); border-radius: 99px; padding: 4px 12px; font-size: .95rem; }
.ti-step-foot .ti-btn { font-size: 1.1rem; }

/* "Learn" cards with pictures (Step 1) */
.ti-learn-card { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: center;
    background: var(--t-panel, #111); border: 3px solid var(--t-line, #333); border-radius: var(--t-radius, 12px); padding: 20px; margin: 18px 0; }
.ti-learn-card.flip { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.ti-learn-card.flip > .ti-pic { order: 2; }
.ti-learn-card h3 { font-family: var(--t-head-font, inherit); font-size: 1.45rem; margin: 0 0 8px; color: var(--t-head, #fff); }
.ti-learn-card p { margin: 8px 0; line-height: 1.55; }
.ti-learn-card .ti-pic svg { width: 100%; height: auto; display: block; }
.ti-learn-card .say { font-size: 1.05rem; background: var(--t-panel2, #222); border-radius: calc(var(--t-radius, 12px) / 1.5); padding: 10px 14px; border-left: 6px solid var(--t-accent2, #0af); }
.ti-word { display: inline-block; background: var(--t-accent2, #0af); color: #fff; border-radius: 8px; padding: 0 8px; font-family: var(--t-head-font, inherit); }
.ti-emoji-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.ti-emoji-row span { display: flex; flex-direction: column; align-items: center; font-size: .85rem; background: var(--t-panel2, #222); border: 2px solid var(--t-line, #333); border-radius: 14px; padding: 6px 10px; min-width: 72px; }
.ti-emoji-row span b { font-size: 2rem; font-weight: 400; line-height: 1.2; }
@media (max-width: 760px) {
    .ti-learn-card { grid-template-columns: 1fr; }
    .ti-learn-card.flip > .ti-pic { order: 0; }
}

/* Quiz pictures */
.ti-q-pic { font-size: 2.4rem; line-height: 1.2; margin-bottom: 4px; }

/* Order game */
.ti-order-game { background: var(--t-panel2, #222); border: 3px solid var(--t-accent2, #0af); border-radius: var(--t-radius, 12px); padding: 16px 18px; margin: 18px 0; }
.ti-order-title { font-family: var(--t-head-font, inherit); font-size: 1.3rem; color: var(--t-accent2, #0af); }
.ti-order-help { margin: 4px 0 10px; }
.ti-order-done { margin: 0 0 10px; padding-left: 1.6em; font-size: 1.1rem; }
.ti-order-done li { margin: 4px 0; padding: 4px 10px; background: color-mix(in srgb, var(--t-ok, #2b5) 14%, var(--t-panel, #fff)); border-radius: 10px; }
.ti-order-pool { display: flex; flex-wrap: wrap; gap: 10px; }
.ti-order-card { font: inherit; font-size: 1.1rem; padding: 12px 16px; border-radius: 14px; cursor: pointer; background: var(--t-panel, #111); color: var(--t-text, #eee); border: 3px solid var(--t-line, #333); box-shadow: 0 4px 0 var(--t-line, #333); }
.ti-order-card:hover { border-color: var(--t-accent2, #0af); }
.ti-order-card.shake { animation: ti-shake .4s; border-color: var(--t-warn, #f90); }
@keyframes ti-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.ti-order-msg { min-height: 1.4em; margin-top: 10px; font-family: var(--t-head-font, inherit); }
.ti-order-msg.good { color: var(--t-ok, #2b5); }
.ti-order-msg.try { color: var(--t-warn, #f90); }
.ti-order-again { margin-top: 8px; }

/* ---------- Robot Playground terms: one colour per school term, a little more grown-up each time ---------- */
body.tier-1.term-2 {
    --t-bg: linear-gradient(180deg, #c9f2d4 0%, #effbf2 50%, #fff6d8 100%);
    --t-head: #1f9e45; --t-accent: #26a84a; --t-line: #b9e6c4; --t-panel2: #f1fbf3; --t-wall: #8fd3a2;
}
body.tier-1.term-3 {
    --t-bg: linear-gradient(180deg, #c4e4ff 0%, #eef6ff 55%, #f6fbff 100%);
    --t-head: #1576c2; --t-accent: #1b86d6; --t-accent2: #8b5cf6; --t-line: #bcd9f3; --t-panel2: #f0f7ff; --t-wall: #8cbbe6;
    --t-size: 1.15rem; --t-radius: 20px;
}
body.tier-1.term-4 {
    --t-bg: linear-gradient(180deg, #e2d6ff 0%, #f5f0ff 55%, #fbf9ff 100%);
    --t-head: #6d3ee0; --t-accent: #7c4ddf; --t-accent2: #e0457b; --t-line: #d8cbf7; --t-panel2: #f7f3ff; --t-wall: #b9a5ef;
    --t-size: 1.12rem; --t-radius: 18px;
}
.term-pill { display: inline-block; margin-left: 6px; font-family: var(--t-head-font, inherit); font-size: .85rem; padding: 4px 12px; border-radius: 99px; background: var(--t-panel2, #eee); color: var(--t-head, #333); border: 2px solid var(--t-line, #ccc); }

/* Term hub */
.ti-term-hub { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; margin: 20px 0 6px; }
.ti-term-hub .ti-stepper-adult { grid-column: 1 / -1; }
.ti-term-card {
    --tc: #ff7a00; position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 16px;
    background: var(--t-panel, #fff); border: 3px solid color-mix(in srgb, var(--tc) 45%, #fff); border-top: 10px solid var(--tc);
    border-radius: var(--t-radius, 16px); box-shadow: 0 6px 0 color-mix(in srgb, var(--tc) 25%, transparent);
}
.ti-term-card.term-2 { --tc: #26a84a; } .ti-term-card.term-3 { --tc: #1b86d6; } .ti-term-card.term-4 { --tc: #7c4ddf; }
.ti-term-card .ti-term-ico { font-size: 2.6rem; line-height: 1; }
.ti-term-card .ti-term-num { font-family: var(--t-head-font, inherit); color: var(--tc); text-transform: uppercase; letter-spacing: .05em; font-size: .85rem; font-weight: 600; }
.ti-term-card h2 { margin: 0; font-family: var(--t-head-font, inherit); color: var(--t-text, #222); font-size: 1.35rem; }
.ti-term-card p { margin: 0; color: var(--t-muted, #666); font-size: 1rem; line-height: 1.45; flex-grow: 1; }
.ti-term-card .ti-progress-bar { height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--tc) 15%, #fff); overflow: hidden; margin-top: 6px; }
.ti-term-card .ti-progress-bar span { display: block; height: 100%; background: var(--tc); border-radius: 99px; }
.ti-term-card .ti-term-status { font-family: var(--t-head-font, inherit); font-size: .95rem; color: var(--t-text, #222); }
.ti-term-card .ti-btn { align-self: flex-start; margin-top: 4px; border-color: var(--tc) !important; color: var(--tc) !important; text-decoration: none; }
.ti-term-card .ti-btn:hover { background: var(--tc) !important; color: #fff !important; }
.ti-term-card.done { background: color-mix(in srgb, var(--tc) 8%, var(--t-panel, #fff)); }
.ti-term-card.locked { opacity: .6; filter: grayscale(.6); }
.ti-step-lock .ti-btn { text-decoration: none; display: inline-block; margin: 4px; }

/* ---------- Weekly lessons ---------- */
.ti-crumb { font-family: var(--t-head-font, inherit); font-size: .9rem; color: var(--t-muted, #777); margin-bottom: 2px; }
.ti-crumb b { color: var(--t-head, #333); }
.ti-goals { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; margin: 14px 0; }
.ti-goals > div { background: var(--t-panel, #fff); border: 3px solid var(--t-line, #ddd); border-radius: var(--t-radius, 16px); padding: 14px 18px; }
.ti-goals h4 { margin: 0 0 6px; font-family: var(--t-head-font, inherit); color: var(--t-head, #333); font-size: 1.15rem; }
.ti-goals ul { margin: 0; padding-left: 1.2em; } .ti-goals li { margin: 4px 0; }
.ti-goals .words span { display: inline-block; margin: 3px 4px 3px 0; }
.ti-home { margin: 22px 0 10px; padding: 14px 18px; border-radius: var(--t-radius, 16px); border: 3px dashed var(--t-accent, #f80); background: color-mix(in srgb, var(--t-accent, #f80) 7%, var(--t-panel, #fff)); }
.ti-home h4 { margin: 0 0 6px; font-family: var(--t-head-font, inherit); color: var(--t-accent, #f80); font-size: 1.15rem; }
.ti-home p { margin: 4px 0; }
.ti-part-title { font-family: var(--t-head-font, inherit); color: var(--t-head, #333); font-size: 1.3rem; margin: 26px 0 4px; }
.ti-std { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 12px; margin: 14px 0; }
.ti-std > div { background: var(--t-panel, #fff); border: 3px solid var(--t-line, #ddd); border-radius: var(--t-radius, 16px); padding: 12px 14px; }
.ti-std .who { font-size: 2.4rem; text-align: center; line-height: 1.1; }
.ti-std .name { text-align: center; font-family: var(--t-head-font, inherit); font-weight: 600; margin-bottom: 6px; }
.ti-std p { margin: 4px 0; font-size: .98rem; }
.ti-pics2 { display: grid; gap: 10px; }
@media (max-width: 760px) { .ti-goals { grid-template-columns: 1fr; } }

/* Sorting game */
.ti-sort-items { display: grid; gap: 8px; }
.ti-sort-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 14px; background: var(--t-panel, #fff); border: 2px solid var(--t-line, #ddd); }
.ti-sort-name { font-size: 1.1rem; }
.ti-sort-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.ti-sort-btn { font: inherit; font-size: .95rem; padding: 6px 12px; border-radius: 99px; cursor: pointer; background: var(--t-panel2, #f6f6f6); color: var(--t-text, #222); border: 2px solid var(--t-line, #ddd); }
.ti-sort-btn:hover { border-color: var(--t-accent2, #0af); }
.ti-sort-btn.shake { animation: ti-shake .4s; border-color: var(--t-warn, #f90); }
.ti-sort-item.right { border-color: var(--t-ok, #2b5); background: color-mix(in srgb, var(--t-ok, #2b5) 10%, var(--t-panel, #fff)); }
.ti-sort-item.right .ti-sort-btn { opacity: .35; pointer-events: none; }
.ti-sort-item.right .ti-sort-btn.chosen { opacity: 1; background: var(--t-ok, #2b5); border-color: var(--t-ok, #2b5); color: #fff; }

/* ---------- Tablets & phones (touch screens) ---------- */
/* No double-tap zoom when a child taps a button twice quickly, no grey flash, no text-selection pop-up on long press */
button, a, label, select, .ti-btn, .ti-block, .ti-opt, .ti-stepper-btn, .ti-order-card, .ti-sort-btn, .ti-grid {
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ti-block, .ti-order-card, .ti-sort-btn, .ti-stepper-btn, .ti-btn, .ti-langs button {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
/* Touch screens have no mouse "hover": stop hover looks from sticking after a tap */
@media (hover: none) {
    .ti-stepper-btn:hover { transform: none; }
    .ti-stepper-btn:not(.current):not(.done):hover { border-color: var(--t-line, #333); }
    .ti-order-card:not(.shake):hover { border-color: var(--t-line, #333); }
    .ti-sort-btn:not(.shake):not(.chosen):hover { border-color: var(--t-line, #ddd); }
}
/* Finger-sized controls; code text at 16px or more so iPads/iPhones don't zoom in when the code is tapped */
@media (pointer: coarse) {
    .ti-editor .CodeMirror, body.themed .ti-editor .CodeMirror, .ti-textarea { font-size: max(16px, var(--t-code-size, 16px)); }
    .ti-langs button { padding: 10px 16px; font-size: 0.95rem; }
    .ti-toolbar .ti-btn { min-height: 44px; }
    .ti-speed, .ti-skip { font-size: 16px; padding: 6px 8px; }
    .ti-link-btn { padding: 8px 6px; }
    .ti-sort-btn { padding: 9px 14px; }
}

/* ---------- Older iPads (iOS 15 and earlier) don't know color-mix(): plain colours instead ---------- */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .ti-bulb { background: #222; border-color: #444; }
    .ti-bulb.on { background: var(--c); }
    body.themed .ti-verdict.pass, body.themed .ti-verdict.fail { background: var(--t-panel2); }
    .ti-block { box-shadow: 0 5px 0 rgba(0, 0, 0, .3); }
    .ti-block:active { box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
    .ti-stepper-btn.current { box-shadow: 0 6px 0 rgba(0, 0, 0, .12); }
    .ti-stepper-btn.done, .ti-step-foot.ready, .ti-order-done li, .ti-sort-item.right, .ti-term-card.done { background: var(--t-panel2, #f3f3f3); }
    .ti-term-card { border-color: var(--t-line, #ddd); border-top-color: var(--tc); box-shadow: 0 6px 0 rgba(0, 0, 0, .08); }
    .ti-term-card .ti-progress-bar { background: #eee; }
    .ti-home { background: var(--t-panel, #fff); }
}
