/* Stamp Game */
.tool-stage .sg-hud{position:absolute;inset:0;pointer-events:none}
.sg-hud .btn{position:absolute;pointer-events:auto;font-size:.8em;padding:0 .6em;min-height:max(2.4em,40px)}
.sg-hud .btn.short .long{display:none}
#mat .stamp .o{stroke-width:var(--sw,2px)}
#mat .stamp.tiny text{display:none}
#mat .sg-stamps>.stamp{cursor:grab}
#mat .sg-tray{cursor:pointer;outline:none}
#mat .sg-tray:focus-visible .o{stroke:var(--gold);stroke-width:4px}
#mat .sg-lift{pointer-events:none;filter:drop-shadow(0 6px 6px rgba(20,26,34,.3))}
#mat .sg-sumline{font-variant-numeric:tabular-nums}
/* the wooden box: the one place for a brown material colour */
#mat .sg-box{fill:#a9713c;stroke:#5e3a1a;stroke-width:2}
#mat .sg-box-in{fill:#b98049;stroke:#7a4c24;stroke-width:1.5}
#mat .sg-plank{stroke:#8e5d30;stroke-width:1.5}
#mat .sg-badge{fill:#fff;stroke:var(--ink);stroke-width:2}
#mat .sg-badge.hot{fill:var(--red)}
#mat .sg-col{fill:#fff;stroke:var(--ink);stroke-width:2}
#mat .sg-div{stroke:var(--ink);stroke-width:2;stroke-dasharray:6 5;opacity:.55}
#mat .sg-cut{stroke:var(--red);stroke-width:2.5;stroke-dasharray:8 6}
#mat .sg-pill{fill:#fff;stroke:var(--red);stroke-width:2}

#side{width:19em;gap:.5em;padding-bottom:2.2em;overflow:hidden}
.sg-left{display:flex;flex-direction:column;gap:.45em}
.sg-card{border:2px solid var(--ink);border-radius:.8em;background:#fff;padding:.35em .7em .5em}
.sg-total{display:flex;flex-direction:column;align-items:center;text-align:center}
.sg-k{font-weight:600;color:var(--soft);font-size:.9em}
.sg-big{font-weight:700;font-size:3em;line-height:1.1;font-variant-numeric:tabular-nums}
.sg-big.hide{color:var(--soft)}
.sg-exp{font-weight:700;font-size:1.15em;line-height:1.35;color:var(--ink);font-variant-numeric:tabular-nums}
.sg-help,.sg-tip{margin:0;font-family:var(--font-body);font-size:.92em;line-height:1.35;color:#39424e}
.sg-tip{font-size:.78em;text-align:center;color:var(--soft);margin-top:.15em}

/* the written sum: one grid column for the sign, four for the places */
.sg-grid{display:grid;grid-template-columns:1.1em repeat(4,1.05em);justify-content:center;align-items:end;font-weight:700;font-size:1.7em;line-height:1.1;font-variant-numeric:tabular-nums}
.sg-grid.div{grid-template-columns:auto repeat(4,1.05em) 2.4em}
.sg-pl{font-size:.38em;text-align:center;color:var(--c);line-height:1.4}
.sg-carry{font-size:.45em;text-align:center;color:var(--red)}
.sg-d{text-align:center;color:var(--c);min-height:1.15em}
.sg-sign{text-align:center;align-self:center}
.sg-rule{grid-column:1/-1;height:.09em;background:var(--ink);border-radius:.05em;margin:.06em 0}
.sg-rem{font-size:.62em;color:var(--ink);white-space:nowrap;padding-left:.25em;align-self:center}
.sg-num{grid-column:span 4;display:grid;grid-template-columns:repeat(4,1fr);min-height:max(1.15em,40px);align-items:center;padding:0;border:2px dashed var(--grid-strong);border-radius:.2em;background:none;font:inherit;color:inherit;cursor:pointer}
.sg-num:hover,.sg-num:focus-visible{border-color:var(--line);outline:none;background:var(--blue-tint)}
.sg-grid.div>.sg-num:first-of-type{grid-column:auto;display:block;padding:0 .2em;color:var(--ink)}
.sg-bracket{border:0;border-top:.09em solid var(--ink);border-left:.09em solid var(--ink);border-radius:.25em 0 0 0}
.sg-bracket:hover,.sg-bracket:focus-visible{border-top-color:var(--ink);border-left-color:var(--ink)}
.sg-in{grid-column:1/-1;width:100%;min-width:0;box-sizing:border-box;font:inherit;text-align:right;letter-spacing:.3em;border:2px solid var(--blue);border-radius:.2em;padding:0 .1em;background:#fff;color:var(--ink)}

/* the steps */
.sg-steps{position:relative;list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:.3em;flex:1 1 auto;min-height:0;overflow:auto;scroll-padding-bottom:1.8em}
/* "more below": a strip with a down arrow that stays at the foot of the list while it can scroll */
.sg-steps.more::after{content:"";position:sticky;bottom:0;flex:none;height:1.5em;margin-top:-1.2em;border-top:2px solid var(--line);background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23141a22' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/1.2em no-repeat}
.sg-step{display:grid;grid-template-columns:1.6em 1fr auto;align-items:center;gap:.2em .45em;padding:.2em .35em;border:2px solid transparent;border-radius:.6em}
.sg-step.now{border-color:var(--blue);background:var(--blue-tint)}
.sg-n{display:grid;place-items:center;width:1.5em;height:1.5em;border-radius:50%;border:2px solid var(--ink);background:#fff;font-weight:700;font-size:.85em}
.sg-step.done .sg-n{background:var(--green);border-color:var(--green);color:transparent;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-size:80%;background-position:center;background-repeat:no-repeat}
.sg-txt,.sg-pick{font-family:var(--font-body);font-size:.92em;line-height:1.3;text-align:left}
.sg-pick{border:0;background:none;padding:.2em 0;color:inherit;cursor:pointer;min-height:40px}
.sg-pick:hover{text-decoration:underline}
.sg-tools{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.35em;align-items:center}
.sg-tools:has(.stepper){grid-column:2/-1;justify-content:flex-start}
.sg-tools .btn.sg-small{font-size:.82em;padding:0 .6em}
.sg-tools .stepper{font-size:.85em}
.sg-tools .ctl.off{opacity:.4;pointer-events:none}
.sg-checkrow{display:flex}
.sg-checkrow .sg-check{flex:1;font-size:1.05em}
#side.busy .sg-tools .btn,#side.busy .sg-check{opacity:.5}

.sg-msg{position:absolute;left:50%;bottom:1.6em;transform:translateX(-50%);width:max-content;max-width:min(30em,calc(100% - 2em));z-index:5;pointer-events:none;display:flex;gap:.5em;align-items:center;font-weight:700;font-size:1.1em;line-height:1.3;border-radius:.7em;padding:.55em .8em;border:3px solid var(--ink);background:#fff;box-shadow:0 .3em .8em rgba(20,26,34,.2)}
.sg-msg:empty{display:none}
.sg-msg.good{background:var(--green-tint);border-color:var(--green)}
.sg-msg.bad{background:var(--red-tint);border-color:var(--red)}
.sg-msg.info{background:var(--gold-tint);border-color:var(--gold)}
.sg-ic{flex:none;width:1.5em;height:1.5em;border-radius:50%;display:grid;place-items:center;color:#fff;background:var(--ink)}
.sg-msg.good .sg-ic{background:var(--green)}
.sg-msg.bad .sg-ic{background:var(--red)}
.sg-msg.info .sg-ic{background:var(--gold);color:var(--ink)}
.sg-ic svg{width:1em;height:1em}

/* tall or narrow tool: the side panel goes under the stage */
@container (max-width:900px){
  .tool-body{flex-direction:column}
  /* a fixed height, so that the stage does not change size when the text changes */
  #side{width:auto;flex-direction:row;flex-wrap:nowrap;align-items:stretch;border-left:0;border-top:2px solid var(--ink);padding:.5em .5em 2.2em;height:40%;flex:none}
  #side>.sg-left{flex:0 1 13em}
  #side>.sg-steps{flex:1 1 15em;max-height:100%}
  #side>.sg-left{overflow:hidden}
  #side.free{flex-wrap:wrap;align-items:flex-start}
  #side.free>*{flex:1 1 12em}
}
@container (max-width:520px){
  .tool-bar .seg .btn{padding:0 .5em}
  #side{height:44%}
  .sg-grid{font-size:1.25em}
  .sg-num{min-height:40px}
  #side>.sg-steps{flex:1 1 9em}
  .sg-step{grid-template-columns:1.4em 1fr;padding:.15em .2em}
  .sg-step .sg-tools{grid-column:2}
}
.tool-frame.tool-max #side,.tool-frame:fullscreen #side{padding-bottom:4em}
/* only the current step shows its buttons, so that all the steps fit; tap a step to make it the current one */
.sg-step:not(.now) .sg-tools{display:none}
.sg-step:not(.now){padding-top:.1em;padding-bottom:.1em}
.sg-steps.less::before{content:"";position:sticky;top:0;z-index:1;flex:none;height:1.5em;margin-bottom:-1.2em;border-bottom:2px solid var(--line);background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 15l6-6 6 6' fill='none' stroke='%23141a22' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/1.2em no-repeat}
.sg-steps.more::after{z-index:1}
