/* ============================================================
   MeGrams — shared theme for the Tangram project
   (Tangrams.html + TangramInteract.html; a future gallery page
   can reuse this file.)
   Palette: porcelain graph-paper field, ink-navy chrome,
   lacquer-vermillion accent, seven facet colors for the pieces.
   Canvas code keeps its own copies of these hexes — if you
   change a facet here, change MGFacets in Tangrams.js and the
   piece colors in TangramInteract.js to match.
   ============================================================ */

:root {
    --porcelain: #eef1f6;
    --paper: #fdfcf7;
    --panel: #ffffff;
    --ink: #1d2433;
    --ink2: #45506b;
    --faint: #8b94a8;
    --edge: #d8dee9;
    --lacquer: #c8372b;
    --lacquer2: #a72a20;
    --ok: #2e7d4f;
    /* the seven facets */
    --f-verm: #d0402f;
    --f-per:  #e8842c;
    --f-gold: #e2a72e;
    --f-jade: #3e9b6e;
    --f-teal: #2e7f96;
    --f-ind:  #3f5aa8;
    --f-plum: #8a4d9e;
    --disp: "Chakra Petch", "Sora", sans-serif;
    --body: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
    --mono: "Spline Sans Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.5;
    /* Engineer's graph paper: 96px = the app's 1 inch, 24px = its quarter inch. */
    background-image:
        linear-gradient(rgba(63, 90, 168, .07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(63, 90, 168, .07) 1px, transparent 1px),
        linear-gradient(rgba(63, 90, 168, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(63, 90, 168, .04) 1px, transparent 1px);
    background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
    background-color: var(--porcelain);
}

a { color: var(--lacquer); }

/* ---------- top bar ---------- */
.mg-topbar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 6px 18px;
    background: var(--ink);
    color: #eef1f6;
    border-bottom: 3px solid var(--lacquer);
}
.mg-topbar a { text-decoration: none; }
.mg-owl img { height: 46px; display: block; }
.mg-wordmark {
    display: inline-flex; align-items: center; gap: 9px;
    font-family: var(--disp); font-weight: 700; font-size: 1.25rem;
    letter-spacing: .02em; color: #eef1f6; white-space: nowrap;
}
.mg-wordmark b { color: #ff7a6b; font-weight: 700; }
.mg-ver {
    font-family: var(--mono); font-style: normal; font-weight: 400;
    font-size: .68rem; color: #9aa4bd; margin-left: .35em; letter-spacing: .06em;
}
.mg-steps { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mg-step {
    display: inline-flex; align-items: center; gap: 7px;
    font-family: var(--disp); font-weight: 600; font-size: .78rem;
    letter-spacing: .12em; color: #b8c0d4;
    padding: .42em .7em; border: 1px solid transparent; cursor: pointer;
}
button.mg-step { background: transparent; }
.mg-step:hover { color: #ffffff; border-color: rgba(238, 241, 246, .25); }
.mg-step.is-active { color: #ffffff; border-color: rgba(238, 241, 246, .45); background: rgba(238, 241, 246, .08); }
.mg-stepnum {
    display: inline-grid; place-items: center;
    width: 18px; height: 18px; font-size: .72rem; font-weight: 700; color: #10141d;
    /* each step wears one piece color */
}
.mg-stepnum.n1 { background: var(--f-verm); clip-path: polygon(0 100%, 100% 100%, 50% 0); }
.mg-stepnum.n2 { background: var(--f-gold); }
.mg-stepnum.n3 { background: var(--f-jade); clip-path: polygon(28% 0, 100% 0, 72% 100%, 0 100%); }
.mg-stepnum.n4 { background: var(--f-plum); clip-path: polygon(25% 0, 100% 0, 75% 100%, 0 100%); color: #fff; }
/* steps stay locked until Part 1's seven puzzles are solved */
.mg-step.is-locked { opacity: .45; }
.mg-step.is-locked::after { content: "🔒"; font-size: .78em; margin-left: 5px; }
.mg-sep { width: 1px; height: 22px; background: rgba(238, 241, 246, .25); margin: 0 6px; }
.mg-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mg-login { font-weight: 700; font-size: .85rem; color: #7fd493 !important; letter-spacing: .04em; }
.mg-login:hover { color: #a9e8b8 !important; }

/* ---------- buttons ---------- */
.mg-btn {
    display: inline-flex; align-items: center; gap: .5em;
    font-family: var(--disp); font-weight: 600; font-size: .82rem;
    letter-spacing: .09em; text-transform: uppercase; text-decoration: none;
    color: var(--ink); background: var(--panel);
    border: 1.5px solid var(--ink); border-radius: 0;
    padding: .5em 1em; cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
    transition: transform .12s ease, background-color .12s ease, color .12s ease;
}
.mg-btn:hover { background: #f2efe6; transform: translateY(-1px); }
.mg-btn:active { transform: translateY(1px); }
.mg-btn--primary { background: var(--lacquer); border-color: var(--lacquer2); color: #fff8f0; }
.mg-btn--primary:hover { background: #d94a3d; }
.mg-btn--ok { background: var(--ok); border-color: #235c3c; color: #f2fbf5; }
.mg-btn--ok:hover { background: #38945f; }
.mg-btn--quiet { border-color: rgba(29, 36, 51, .35); font-weight: 500; }
.mg-btn--quiet:hover { border-color: var(--ink); }
:where(.mg-btn, .mg-step, a, button, summary, input):focus-visible {
    outline: 2px solid var(--lacquer); outline-offset: 2px;
}

/* ---------- shared text bits ---------- */
.mg-eyebrow {
    font-family: var(--mono); font-size: .7rem; font-weight: 600;
    letter-spacing: .22em; text-transform: uppercase; color: var(--ink2);
    margin: 0 0 10px;
}
.mg-marquewrap { flex: 0 0 auto; margin: 0 auto; text-align: center; }
.mg-cap {
    font-family: var(--mono); font-size: .68rem; letter-spacing: .18em;
    text-transform: uppercase; color: var(--faint); margin-top: 10px;
}

/* the seven-piece marque — MeGramsMarque.js sets each piece's transform per
   figure (square / duck / house / scattered); CSS owns the glide.
   Currently only the mini in Tangram Interact's topbar uses it; drop the same
   svg[data-mg-marque] block anywhere to revive the full-size version. */
.mg-marque { display: block; overflow: visible; }
.mg-marque .mg-piece {
    transition: transform 1.15s cubic-bezier(.65, .05, .25, 1);
    transform-box: fill-box; transform-origin: center;
}
.mg-marque .mg-piece:nth-child(2) { transition-delay: .05s; }
.mg-marque .mg-piece:nth-child(3) { transition-delay: .1s; }
.mg-marque .mg-piece:nth-child(4) { transition-delay: .15s; }
.mg-marque .mg-piece:nth-child(5) { transition-delay: .2s; }
.mg-marque .mg-piece:nth-child(6) { transition-delay: .25s; }
.mg-marque .mg-piece:nth-child(7) { transition-delay: .3s; }
.mg-marque--mini { width: 30px; height: 30px; }

/* ---------- part sections ---------- */
.mg-main { max-width: 1150px; margin: 0 auto; padding: 10px 20px 30px; }
.mg-part { padding: 26px 0 8px; }
.mg-parthead { max-width: 72ch; margin-bottom: 16px; }
.mg-parthead .mg-eyebrow { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.mg-glyph { flex: 0 0 auto; display: inline-block; }
.mg-parthead h2 {
    font-family: var(--disp); font-weight: 700; font-size: 1.9rem;
    letter-spacing: .02em; margin: 0 0 8px; color: var(--ink);
}
.mg-guide { margin: 0; color: var(--ink2); max-width: 68ch; }
.mg-guide kbd, .mg-keys kbd, .mg-btn kbd {
    font-family: var(--mono); font-size: .82em; color: var(--ink);
    background: var(--paper); border: 1px solid var(--edge);
    border-bottom-width: 2.5px; border-radius: 4px; padding: .08em .45em;
}
.mg-toolrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.mg-toolnote { font-size: .84rem; color: var(--faint); margin: 0; }

/* Part 1 design criteria — the five checks a MeGram must meet. Same cut-corner
   panel language as .mg-btn; filter (not box-shadow) so the shadow follows the
   clip-path. Each list glyph literally shows its criterion. */
.mg-criteria {
    max-width: 640px; margin: 0 0 20px;
    background: var(--panel); border: 1.5px solid var(--ink);
    padding: 14px 18px 15px;
    clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%);
    filter: drop-shadow(5px 6px 0 rgba(29, 36, 51, .10));
}
.mg-criteria .mg-eyebrow { margin: 0 0 10px; }
.mg-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mg-checks li {
    display: grid; grid-template-columns: 22px 1fr auto; align-items: start; gap: 9px;
    font-size: .92rem; line-height: 1.45; color: var(--ink2);
    padding: 3px 8px 3px 6px; margin: 0 -6px;
}
.mg-checks li b { color: var(--ink); }
.mg-checks svg { margin-top: 2px; }

/* CHECK results — MGCheckCriteria() paints each row, MGClearCheck() wipes them
   whenever the drawing or the traced pieces change */
.mg-checks li.mg-pass { background: rgba(62, 155, 110, .09); }
.mg-checks li.mg-fail { background: rgba(200, 55, 43, .07); }
.mg-checkres {
    grid-column: 3; align-self: center; font-family: var(--mono); font-style: normal;
    font-size: .76rem; letter-spacing: .02em; white-space: nowrap;
}
.mg-pass .mg-checkres { color: var(--ok); }
.mg-fail .mg-checkres { color: var(--lacquer2); }
.mg-dotc {
    display: inline-block; width: 9px; height: 9px; margin: 0 2px 0 1px;
    vertical-align: -1px; border: 1px solid rgba(29, 36, 51, .3);
}
.mg-checkbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.mg-checkverdict {
    margin: 0; font-family: var(--mono); font-size: .74rem; font-weight: 600;
    letter-spacing: .18em; text-transform: uppercase;
}
.mg-checkverdict.ok { color: var(--ok); }
.mg-checkverdict.no { color: var(--lacquer); }

/* ---------- Part 1: Solve the seven (embedded Tangram Interact) ---------- */
.mg-puzrail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.mg-puz .mg-tag {
    font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
    color: var(--faint); margin-right: .5em; text-transform: lowercase;
}
.mg-puz.is-current { border-color: var(--lacquer); box-shadow: inset 0 0 0 1px var(--lacquer); }
.mg-puz.is-done { background: rgba(62, 155, 110, .12); border-color: var(--ok); color: var(--ok); }
.mg-puz.is-done::before { content: "✓ "; font-weight: 700; }
.mg-puz.is-done .mg-tag { color: var(--ok); }
.mg-puzprog {
    margin-left: 8px; font-family: var(--mono); font-size: .74rem; font-weight: 600;
    letter-spacing: .16em; text-transform: uppercase; color: var(--ink2);
}
.mg-interactframe {
    display: block; width: 100%; height: 800px;
    border: 1.5px solid var(--ink); background: var(--porcelain);
}
/* embed mode (?embed=1) — this page inside the maker's Part 1 iframe:
   no standalone chrome, tighter board padding; parent drives the puzzles */
.mg-embed .mg-topbar, .mg-embed .mg-sub, .mg-embed .mg-foot { display: none; }
.mg-embed .mg-board { padding: 12px 14px 18px; }

/* ---------- final PRINT document: letter-proportioned pages ---------- */
.mg-finalsheets { display: flex; flex-direction: column; gap: 20px; align-items: center; }
.mg-page {
    background: #fff; border: 1.5px solid var(--ink);
    width: 100%; max-width: 760px; aspect-ratio: 8.5 / 11;
    padding: 5.5% 6.5%; overflow: hidden;
    display: flex; flex-direction: column;
    filter: drop-shadow(6px 7px 0 rgba(29, 36, 51, .10));
}
.mg-pgeyebrow {
    font-family: var(--mono); font-size: .7rem; font-weight: 600;
    letter-spacing: .22em; text-transform: uppercase; color: var(--ink2);
    margin: 0 0 10px; flex: 0 0 auto;
}
/* cover: title block on top, the -Gram centered in the leftover space */
.mg-pgcover { text-align: center; }
.mg-pgtitle {
    font-family: var(--disp); font-weight: 700; font-size: 2.4rem;
    letter-spacing: .02em; color: var(--ink); margin: 6px 0 0;
}
.mg-pgart { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-height: 0; }
.mg-pgart svg { width: min(76%, 5.4in); height: auto; display: block; }
.mg-pgfoot {
    font-family: var(--mono); font-size: .72rem; letter-spacing: .14em;
    text-transform: uppercase; color: var(--ink2); margin: 8px 0 0;
}
/* ---------- the student gallery (Gallery.html) ---------- */
.mg-galwrap { max-width: 1150px; margin: 0 auto; padding: 6px 20px 40px; }
.mg-galyear {
    font-family: var(--disp); font-weight: 700; font-size: 1.15rem;
    letter-spacing: .03em; color: var(--ink); margin: 20px 0 10px;
}
.mg-galgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.mg-galcard {
    margin: 0; background: var(--panel); border: 1.5px solid var(--ink);
    padding: 10px 10px 8px;
    clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%);
    filter: drop-shadow(5px 6px 0 rgba(29, 36, 51, .10));
}
.mg-galcard canvas { display: block; width: 100%; border: 1px solid var(--edge); }
.mg-galcard figcaption {
    font-family: var(--disp); font-weight: 600; font-size: .84rem;
    letter-spacing: .05em; margin-top: 7px; color: var(--ink); text-align: center;
}
.mg-galstatus {
    font-family: var(--mono); font-size: .72rem; font-weight: 600;
    letter-spacing: .18em; text-transform: uppercase; color: var(--ink2); margin: 10px 0 0;
}

/* standards page (Music of Me format: section→standard table + full texts) */
.mg-pgdir { font-size: .84rem; color: var(--ink2); margin: 0 0 10px; }
.mg-stdtbl { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: .84rem; color: var(--ink); }
.mg-stdtbl th, .mg-stdtbl td { border: 1px solid var(--ink); padding: 6px 12px; text-align: left; }
.mg-stdtbl th { font-family: var(--disp); font-size: .8rem; letter-spacing: .04em; }
.mg-stdtbl .mg-stdcode {
    width: 130px; text-align: center; white-space: nowrap;
    font-family: var(--mono); font-size: .72rem; font-weight: 700;
}
.mg-pgsubhead { font-family: var(--disp); font-weight: 700; font-size: .95rem; margin: 0 0 6px; color: var(--ink); }
.mg-stdlist { margin: 0; }
.mg-stdlist dt {
    font-family: var(--mono); font-size: .76rem; font-weight: 700;
    letter-spacing: .05em; margin-top: 11px; color: var(--ink);
}
.mg-stdlist dd { margin: 3px 0 0; font-size: .84rem; line-height: 1.5; color: var(--ink2); }
.mg-stdlist dd ol { list-style: lower-alpha; margin: 4px 0 0; padding-left: 1.6em; }
.mg-stdlist dd ol li { margin: 2px 0; }

/* puzzle pages: TWO full-width rows per page — the solved board big on the
   left, the COMPLETE transformation list beside it (the math on display) */
.mg-puzrows { display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; min-height: 0; }
.mg-finalcard { background: var(--panel); border: 1px solid var(--edge); padding: 8px 12px 10px; overflow: hidden; }
.mg-puzrowcard { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.mg-finalcard h4 {
    font-family: var(--disp); font-weight: 700; font-size: 1rem;
    margin: 0 0 6px; color: var(--ink);
}
.mg-puzbody { display: flex; gap: 16px; align-items: flex-start; flex: 1 1 auto; min-height: 0; }
.mg-puzbody canvas { display: block; width: 44%; border: 1px solid var(--edge); }
.mg-finalcmds {
    flex: 1 1 auto; margin: 0; padding-left: 1.6em;
    font-family: var(--mono); font-size: .72rem; line-height: 1.55; color: var(--ink2);
}
.mg-finalcmds.is-long { columns: 2; column-gap: 18px; }
.mg-finalcard.is-missing { border-style: dashed; border-color: var(--faint); }
.mg-finalcard.is-missing p { margin: 0; font-size: .74rem; color: var(--faint); }
/* design page: criteria in TWO COLUMNS on top, the drawing below at true
   scale (printed 6.875in wide -> the six-inch square is exactly 6") */
.mg-pgcrits { flex: 0 0 auto; margin: 0 0 10px; }
.mg-pgcrits h4 { font-family: var(--disp); font-size: .95rem; margin: 0 0 8px; color: var(--ink); }
.mg-pgcritlist {
    list-style: none; margin: 0; padding: 0; font-size: .8rem; color: var(--ink2);
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px;
}
.mg-pgcritlist b { font-family: var(--mono); margin-right: 4px; color: var(--faint); }
.mg-pgcritlist .is-pass b { color: var(--ok); }
.mg-pgcritlist .is-fail b { color: var(--lacquer); }
.mg-pgdesignwrap { flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; align-items: flex-start; }
.mg-pgdesignwrap canvas { width: min(100%, 640px); }
/* booklet pages: the sheet canvas IS the page */
.mg-page.mg-pgfull { padding: 0; }
.mg-pgsheet { display: block; width: 100%; height: auto; }
.mg-pgempty { color: var(--faint); font-size: .9rem; }
@media print {
    @page { size: letter; margin: 0.4in; }
    .mg-topbar, .mg-toast, .mg-finalbar, .mg-canvastools,
    #FinalPrintContainer .mg-parthead { display: none !important; }
    body { background: none; background-color: #fff; }
    .mg-main { max-width: none; padding: 0; }
    .mg-part { padding: 0; }
    .mg-finalsheets { display: block; }
    .mg-page {
        width: 100%; max-width: none; aspect-ratio: auto; height: 10.1in;
        border: none; filter: none; padding: 0; margin: 0;
        break-after: page; overflow: hidden;
    }
    .mg-page:last-child { break-after: auto; }
    .mg-finalcard { break-inside: avoid; }
    /* 660px backing at 96dpi: the inner six-inch square prints EXACTLY 6" */
    .mg-pgdesignwrap canvas { width: 6.875in; }
}

/* canvas frames — the cutting mat */
.mg-lift { filter: drop-shadow(6px 7px 0 rgba(29, 36, 51, .10)); position: relative; }
/* floating tool icons pinned to the frame's top-left corner — they stay put
   while the wide canvas scrolls underneath */
.mg-canvastools { position: absolute; top: 9px; left: 16px; z-index: 5; display: flex; gap: 6px; }
.mg-canvastools--right { left: auto; right: 34px; } /* clears the frame's cut corner */
.mg-tool {
    width: 36px; height: 36px; display: grid; place-items: center;
    font-size: 19px; line-height: 1; cursor: pointer; padding: 0;
    color: var(--ink); background: var(--panel);
    border: 1.5px solid var(--ink);
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
    transition: background-color .12s ease, transform .12s ease;
}
.mg-tool:hover { background: #f2efe6; transform: translateY(-1px); }
.mg-tool:active { transform: translateY(1px); }
.mg-tool--wide {
    width: auto; padding: 0 10px;
    font-family: var(--disp); font-weight: 600; font-size: .66rem; letter-spacing: .08em;
}
/* the "Add to booklet" chip — appears on the canvas only once a silhouette exists */
.mg-tool--primary { background: var(--lacquer); border-color: var(--lacquer2); color: #fff8f0; }
.mg-tool--primary:hover { background: #d94a3d; }
.mg-frame {
    background: var(--paper);
    border: 2px solid var(--ink);
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
    padding: 14px; overflow-x: auto;
    max-width: 100%;
    overscroll-behavior-x: contain;
}
.mg-frame canvas { display: block; margin: 0 auto; background: transparent; border: 0; }
/* Piece canvases: the browser gets NO gestures here (compound touch-action
   values are flaky on iOS — "none" is honored everywhere). The JS handles
   everything itself: dragging a piece, and panning the frame sideways when a
   finger moves on empty canvas. Touching outside the canvas scrolls normally. */
#TangramCanvas3, #canvas { touch-action: none; }

/* keyboard legend */
.mg-keys {
    margin: 0 0 14px; padding: 10px 16px; max-width: 640px;
    background: var(--panel); border: 1.5px solid var(--edge);
}
.mg-keys summary {
    cursor: pointer; user-select: none;
    font-family: var(--disp); font-weight: 600; font-size: .82rem;
    letter-spacing: .1em; text-transform: uppercase; color: var(--ink2);
}
.mg-keys summary:hover { color: var(--ink); }
.mg-keys table { border-collapse: collapse; margin: 10px 0 6px; }
.mg-keys td { padding: 4px 16px 4px 0; font-size: .9rem; color: var(--ink2); }
.mg-keys td:first-child { white-space: nowrap; }
.mg-keys .mg-toolnote { margin-top: 4px; }

/* ---------- export panels ---------- */
.mg-exportcard {
    background: var(--panel); border: 1.5px solid var(--edge);
    padding: 18px 20px; max-width: 760px;
}
/* per-puzzle remove buttons overlaid on the booklet's front-sheet preview —
   percent-positioned so they track the scaled canvas */
.mg-sheetwrap { position: relative; display: inline-block; max-width: 100%; }
.mg-cellx {
    position: absolute; width: 26px; height: 26px; padding: 0;
    display: grid; place-items: center; cursor: pointer;
    font-size: 13px; font-weight: 700; line-height: 1;
    color: var(--lacquer2); background: var(--panel);
    border: 1.5px solid var(--lacquer2); border-radius: 50%;
}
.mg-cellx:hover { background: var(--lacquer); color: #fff8f0; }

/* two export cards sharing a row (the SVG page) */
.mg-exportrow { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.mg-exportrow .mg-exportcard { flex: 1 1 380px; min-width: 320px; max-width: none; }
.mg-exportrow .mg-cap { text-align: left; margin: 0 0 10px; }
.mg-exportcard .mg-toolrow { margin-bottom: 10px; }
/* Both previews are 6"x6" areas — render them at identical size by filling
   their (equal-width) cards, regardless of each file's intrinsic px size. */
#SVGDownloadCanvas svg, #EtchDownloadCanvas svg { width: 100%; height: auto; border: 1px dashed var(--edge); background: var(--paper); }
#PrintDownloadCanvas, #BookletContainer canvas { max-width: 100%; height: auto; border: 1px dashed var(--edge); background: #ffffff; }
.mg-exportcard .mg-cap { text-align: left; margin: 16px 0 8px; }
#BookletCount { margin-right: 4px; }
#BookletCount b { color: var(--ink); }

/* solved-puzzle confetti overlay (Tangram Interact) */
.mg-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; }

/* ---------- toast ---------- */
.mg-toast {
    position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
    background: var(--ink); color: #eef1f6;
    font-family: var(--disp); font-size: .85rem; letter-spacing: .05em;
    padding: .65em 1.3em; opacity: 0; pointer-events: none;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
    transition: opacity .25s ease, transform .25s ease;
    z-index: 60;
}
.mg-toast.show { opacity: 1; transform: translate(-50%, 0); }
.mg-toast.bad { background: var(--lacquer2); }

/* ---------- footer ---------- */
.mg-foot {
    max-width: 1150px; margin: 10px auto 0; padding: 18px 20px 30px;
    border-top: 1px solid var(--edge);
    font-size: .82rem; color: var(--faint);
}
.mg-foot a { color: var(--ink2); }

/* ============================================================
   Tangram Interact page
   ============================================================ */
.mg-sub {
    max-width: 1150px; margin: 0 auto; padding: 26px 20px 0;
}
.mg-sub h1 {
    font-family: var(--disp); font-weight: 700; font-size: clamp(1.7rem, 4vw, 2.4rem);
    margin: 0 0 8px; color: var(--ink); letter-spacing: .01em;
}
.mg-board { max-width: 1150px; margin: 0 auto; padding: 14px 20px 30px; }
.mg-playrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.mg-playhint { font-family: var(--mono); font-size: .74rem; letter-spacing: .04em; color: var(--faint); }

/* command bar */
.mg-cmd { display: flex; gap: 0; flex-wrap: wrap; margin: 0 0 14px; max-width: 760px; }
.mg-cmd .mg-drop { flex: 0 0 auto; }
.mg-cmd input {
    flex: 1 1 260px; min-width: 200px;
    font-family: var(--mono); font-size: .95rem; color: var(--ink);
    background: var(--panel); border: 1.5px solid var(--ink); border-left: 0; border-right: 0;
    padding: .5em .9em;
}
.mg-cmd input::placeholder { color: var(--faint); }

/* hand-rolled dropdowns (Bootstrap is gone) */
.mg-drop { position: relative; display: inline-block; }
.mg-dropbtn::after { content: " ▾"; font-size: .85em; }
.mg-menu {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 40;
    min-width: 210px; margin: 0; padding: 5px; list-style: none;
    background: var(--panel); border: 1.5px solid var(--ink);
    filter: drop-shadow(4px 5px 0 rgba(29, 36, 51, .12));
    display: none;
}
.mg-drop.open .mg-menu { display: block; }
.mg-menu a {
    display: block; padding: .45em .7em; text-decoration: none;
    font-size: .92rem; color: var(--ink);
}
.mg-menu a:hover { background: var(--porcelain); color: var(--lacquer2); }
.mg-menu .mg-tag {
    font-family: var(--mono); font-size: .68rem; letter-spacing: .08em;
    color: var(--faint); margin-right: .5em; text-transform: uppercase;
}

/* board row: canvas + transformation list */
.mg-boardrow { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; background: transparent; }
.mg-listcard {
    flex: 1 1 320px; min-width: 280px; align-self: stretch;
    background: var(--panel); border: 1.5px solid var(--edge);
    padding: 14px 18px;
}
.mg-listcard h4 {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-family: var(--disp); font-weight: 600; font-size: .88rem;
    letter-spacing: .12em; text-transform: uppercase; color: var(--ink2);
    margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--edge);
}
#CommandList { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: mgcmd; }
#CommandList li {
    font-family: var(--mono); font-size: .86rem; color: var(--ink);
    padding: .42em 0 .42em 2.1em; position: relative;
    border-bottom: 1px dashed var(--edge);
    counter-increment: mgcmd;
}
#CommandList li::before {
    content: counter(mgcmd, decimal-leading-zero);
    position: absolute; left: 0; top: .5em;
    font-size: .72rem; color: var(--faint); letter-spacing: .05em;
}

/* ---------- responsive & motion ---------- */
@media (max-width: 720px) {
    .mg-topbar { padding: 6px 12px; }
    .mg-marquewrap { flex-basis: 100%; }
    .mg-boardrow { gap: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .mg-marque .mg-piece { transition: none; }
    .mg-btn, .mg-toast { transition: none; }
}
