[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:root {
  --slate: #262d31; --slate-deep: #1d2327; --wood: #7a5230; --wood-dark: #4f3520; --chalk: #efeadd; --dim: #aab2b0;
  --yellow: #f4d35e; --pink: #f6a59d; --blue: #9bd3ec; --teal: #1fa7b8; --tin: #e6e0d0; --ink: #1f2428;
  --hand: 'Cabin Sketch', 'Trebuchet MS', sans-serif; --title: 'Fredericka the Great', Georgia, serif; --body: 'Atkinson Hyperlegible', Verdana, sans-serif;
  --sm-bg: #262d31; --sm-text: #efeadd; --sm-muted: #aab2b0; --sm-accent: #f4d35e; --sm-hover: #333c41; --sm-up: #a7d49b; --sm-down: #f6a59d;
  --sm-font: 'Atkinson Hyperlegible', Verdana, sans-serif; --sm-head: 'Fredericka the Great', Georgia, serif; --sm-head-weight: 400; --sm-size: 17px;
  --sm-radius: 4px; --sm-border: 4px solid #7a5230; --sm-shadow: 0 14px 34px rgba(0, 0, 0, .5);
  --sm-top: 64px; --sm-right: calc(8px + env(safe-area-inset-right, 0px));
}
* { box-sizing: border-box; }
html { font-size: 100%; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--slate-deep); color: var(--chalk); font-family: var(--body); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

#app { position: fixed; inset: 0; height: 100vh; height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 38fr) minmax(0, 62fr); }
#trackWrap { position: relative; overflow: hidden; min-height: 0; background: #3a3f45; }
#track { position: absolute; left: 0; top: 0; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* the track's name: an offcut of slate, top left */
.chip { position: absolute; left: max(.5rem, env(safe-area-inset-left)); top: max(.4rem, env(safe-area-inset-top)); display: flex; align-items: center; gap: .55rem; min-height: 2.75rem; max-width: calc(100% - 5rem);
  padding: .1rem .8rem .1rem .6rem; background: var(--slate); border: 3px solid var(--wood); border-radius: 3px; box-shadow: 2px 3px 0 rgba(0, 0, 0, .35); }
.chip .no { font-family: var(--title); font-size: 1.7rem; line-height: 1; color: var(--yellow); }
.chip .nm { font-family: var(--hand); font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .nm::after { content: ' ▾'; color: var(--dim); }

/* the Sloppy menu: a slate tab hanging from the top edge, a chalk face on it */
.tab { position: fixed; z-index: 6; top: 0; right: max(8px, env(safe-area-inset-right)); width: 52px; height: 56px; padding: 0; border: 0; background: none; }
.tab svg { display: block; width: 100%; height: 100%; overflow: visible; transform-origin: 50% 0; filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, .35)); }
.tab .eyes > *, .tab .lines > *, .tab .mouth { transform-box: fill-box; transition: transform .2s ease, opacity .2s ease; }
.tab .eyes > * { transform-origin: center; }
.tab .lines > * { transform-origin: left center; transform: scaleX(0); }
.tab .lines > :nth-child(2) { transition-delay: .05s; } .tab .lines > :nth-child(3) { transition-delay: .1s; }
.tab:hover .eyes > *, .tab:focus-visible .eyes > *, .tab.cue .eyes > *, .sm-open .tab .eyes > * { transform: scaleY(0); }
.tab:hover .mouth, .tab:focus-visible .mouth, .tab.cue .mouth, .sm-open .tab .mouth { opacity: 0; }
.tab:hover .lines > *, .tab:focus-visible .lines > *, .tab.cue .lines > *, .sm-open .tab .lines > * { transform: scaleX(1); }
.tab:hover svg, .tab.cue svg { animation: knock 1.1s ease-out; }
.tab:focus-visible { outline-offset: -4px; }
@keyframes knock { 0% { transform: rotate(0); } 18% { transform: rotate(7deg); } 42% { transform: rotate(-5deg); } 68% { transform: rotate(2deg); } 100% { transform: rotate(0); } }

/* the finish card: the result, chalked across the slate above the program */
.card { flex: none; display: flex; align-items: center; gap: .7rem; padding: .35rem .6rem .35rem .8rem; border-bottom: 2px dashed rgba(239, 234, 221, .22); background: rgba(244, 211, 94, .09); animation: rise .3s ease-out; }
@keyframes rise { from { transform: translateY(-.6rem); } to { transform: none; } }
.card .stars { display: flex; gap: .05rem; font-size: 1.9rem; line-height: 1; color: #59646a; }
.card .stars .on { color: var(--yellow); animation: star .4s cubic-bezier(.3, 1.8, .5, 1) backwards; }
@keyframes star { from { transform: scale(2.2) rotate(-25deg); } to { transform: none; } }
.card .nums { margin: 0; flex: 1; font-family: var(--hand); font-size: 1.05rem; line-height: 1.15; }
.card .nums span { white-space: nowrap; }
.card .nums .ok { color: var(--yellow); } .card .nums .no { color: var(--pink); text-decoration: underline wavy; text-underline-offset: 3px; }
.card .next { flex: none; min-height: 2.75rem; padding: 0 .8rem; font-family: var(--title); font-size: 1.15rem; white-space: nowrap; color: var(--ink); background: var(--yellow); border: 2px solid var(--ink); border-radius: 4px; box-shadow: 0 3px 0 var(--ink); }
.card .next:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* the slate */
#slate { min-height: 0; min-width: 0; display: flex; flex-direction: column; border-top: .55rem solid var(--wood);
  background:
    radial-gradient(ellipse 60% 30% at 30% 20%, rgba(255, 255, 255, .055), transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 70%, rgba(255, 255, 255, .04), transparent 70%),
    repeating-linear-gradient(101deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 7px),
    var(--slate);
  box-shadow: inset 0 6px 8px -4px rgba(0, 0, 0, .5); }
.head { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem .1rem; }
.marlene { flex: none; width: 2.5rem; height: 2.5rem; }
#say { margin: 0; flex: 1; min-height: 2.5em; display: flex; align-items: center; font-family: var(--hand); font-size: 1.12rem; line-height: 1.2; color: var(--chalk); overflow-wrap: anywhere; }
#say.new { animation: write .35s ease-out; }
@keyframes write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.meta { display: flex; align-items: center; gap: .7rem; padding: 0 .7rem .2rem; border-bottom: 2px dashed rgba(239, 234, 221, .22); }
.tally { display: inline-flex; align-items: center; gap: 5px; height: 1.7rem; padding: 0 .2rem; }
.tally i { display: block; width: 3px; height: 1.15rem; border-radius: 2px; background: #56626a; transform: rotate(4deg); }
.tally i:nth-child(2n) { transform: rotate(-3deg); }
.tally i.fifth { height: 1.75rem; margin-left: -19px; margin-right: 14px; transform: rotate(-66deg); }
.tally i.on { background: var(--chalk); }
.tally.over i.on { background: var(--pink); }
.par { flex: 1; font-size: .85rem; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wipe { min-height: 2.75rem; padding: 0 .7rem; background: none; border: 0; font-family: var(--hand); font-size: 1.05rem; color: var(--pink); text-decoration: underline; text-underline-offset: 3px; }
.share { color: var(--blue); padding: 0 .4rem; }
.sent { flex: none; margin: 0; padding: .25rem .8rem; font-family: var(--hand); font-size: .98rem; color: var(--blue); border-bottom: 2px dashed rgba(239, 234, 221, .22); }
.sharebox { flex: none; display: flex; align-items: center; gap: .4rem; padding: .2rem .4rem .2rem .8rem; border-bottom: 2px dashed rgba(239, 234, 221, .22); }
.sharebox label { font-size: .8rem; color: var(--dim); white-space: nowrap; }
.sharebox input { flex: 1; min-width: 0; min-height: 2.4rem; padding: 0 .5rem; font: inherit; font-size: .85rem; color: var(--chalk); background: rgba(0, 0, 0, .25); border: 1px solid rgba(239, 234, 221, .35); border-radius: 4px; }
.card .share { flex: none; min-height: 2.75rem; }
/* v1.6: shortest anyone, one quiet line under the result */
.card { flex-wrap: wrap; row-gap: 0; }
.card .board { flex: 1 0 100%; order: 9; display: flex; align-items: center; gap: .3rem; margin: -.25rem 0 0; font-size: .85rem; color: var(--dim); min-height: 1.6rem; }
.card .board .share { min-height: 2.4rem; padding: 0 .4rem; font-size: 1rem; }
.sent.peek { display: flex; align-items: center; gap: .4rem; padding-top: 0; padding-bottom: 0; }
.sent.peek span { flex: 1; min-width: 0; }
.sent.peek .wipe { flex: none; min-height: 2.5rem; padding: 0 .3rem; font-size: 1rem; }
.wipe:disabled { color: #7c868a; text-decoration: none; cursor: default; }

.prog { flex: 1; min-height: 3rem; margin: 0; padding: .2rem .5rem .3rem; list-style: none; overflow-y: auto; overscroll-behavior: contain; }
.prog.full { animation: full .3s; }
@keyframes full { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.prog li { --d: 0; display: flex; align-items: center; gap: .2rem; padding-left: calc(var(--d) * 1.25rem); border-radius: 3px;
  background-image: repeating-linear-gradient(90deg, transparent 0 .5rem, rgba(155, 211, 236, .8) .5rem calc(.5rem + 4px), transparent calc(.5rem + 4px) 1.25rem);
  background-size: calc(var(--d) * 1.25rem) 100%; background-repeat: no-repeat; }
.ln { min-height: 2.75rem; flex-wrap: wrap; }   /* deep in loops on a phone, a picked line's buttons drop to a second row */
.ln .cmd { flex: 1 0 auto; white-space: nowrap; min-height: 2.75rem; display: flex; align-items: center; gap: .5rem; padding: 0 .3rem; background: none; border: 0; text-align: left; font-family: var(--hand); font-size: 1.3rem; letter-spacing: .03em; color: var(--chalk); }
.ln .no { flex: none; width: 1rem; font-family: var(--body); font-size: .8rem; color: var(--dim); text-align: right; }
.ln .num { font-size: 1.55rem; color: var(--yellow); }
.kREP .tx { color: var(--blue); } .kIF .tx { color: var(--blue); } .kH .tx { color: var(--pink); }
.else { min-height: 2.75rem; } .else .tx { color: var(--blue); }
.ln.sel { background-color: rgba(239, 234, 221, .09); box-shadow: inset 0 0 0 2px rgba(239, 234, 221, .5); }
.ln.in .tx { text-decoration: underline; text-decoration-color: var(--yellow); text-underline-offset: 4px; }
.ln.lit { background-color: rgba(244, 211, 94, .2); box-shadow: inset 4px 0 0 var(--yellow); }
.ln.lit .tx { color: var(--yellow); }
.ctl { flex: none; margin-left: auto; display: flex; gap: .25rem; padding: 0 .2rem; }
.ctl button { width: 2.75rem; height: 2.75rem; padding: 0; background: var(--slate-deep); border: 2px solid var(--chalk); border-radius: 50%; font-family: var(--body); font-weight: 700; font-size: 1.3rem; line-height: 1; }
.ctl .rm { border-color: var(--pink); color: var(--pink); font-size: 1rem; }
.ctl button:active { transform: scale(.92); }
.caret { min-height: 1.5rem; gap: .6rem !important; }
.caret .cur { width: 1.1rem; height: 4px; margin-left: 1.6rem; border-radius: 2px; background: var(--yellow); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.caret .empty { font-size: .85rem; color: var(--dim); }
.caret .out { min-height: 2.75rem; padding: 0 .8rem; background: none; border: 2px dashed var(--blue); border-radius: 4px; font-size: .85rem; color: var(--blue); }
.caret .empty + .out { margin-left: auto; }
/* a block's bracket: a corner under REPEAT / IF, the line down its body, a foot that says what happens */
.prog li { position: relative; }
.ln.blk::after { content: ''; position: absolute; left: calc(var(--d) * 1.25rem + .5rem); bottom: 0; width: .9rem; height: .55rem;
  border: solid rgba(155, 211, 236, .8); border-width: 4px 0 0 4px; border-top-left-radius: 6px; pointer-events: none; }
.ln.else::before { content: ''; position: absolute; left: calc(var(--d) * 1.25rem + .5rem); inset-block: 0;
  border-left: 4px solid rgba(155, 211, 236, .8); pointer-events: none; }
.ln .times { font-family: var(--body); font-size: .8rem; color: var(--blue); letter-spacing: 0; }
.bfoot { min-height: 1.7rem; align-items: stretch !important; gap: .35rem !important; }
.bfoot .hook { flex: none; width: .9rem; height: .85rem; margin-left: .5rem; border: solid rgba(155, 211, 236, .8); border-width: 0 0 4px 4px; border-bottom-left-radius: 6px; }
.bfoot .ft { align-self: center; padding-top: .55rem; font-size: .8rem; color: var(--blue); }
.bfoot.hole { cursor: pointer; }
.bfoot.hole .ft { padding: .2rem .5rem; margin-top: .45rem; border: 2px dashed rgba(155, 211, 236, .7); border-radius: 4px; }
/* moving lines */
.ln[data-id] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.ctl .grip { border-color: var(--blue); color: var(--blue); touch-action: none; cursor: grab; }
.prog li.dragging { opacity: .35; }
.dropmark { position: fixed; z-index: 40; height: 4px; border-radius: 2px; background: var(--yellow); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); pointer-events: none; }
.dropmark::before { content: ''; position: absolute; left: -6px; top: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--yellow); }
.dragghost { position: fixed; left: 0; top: 0; z-index: 41; padding: .25rem .6rem; border: 2px solid var(--chalk); border-radius: 4px; background: var(--slate-deep);
  font-family: var(--hand); font-size: 1.15rem; color: var(--chalk); white-space: nowrap; pointer-events: none; box-shadow: 0 6px 14px rgba(0, 0, 0, .45); }
html.dragging-line, html.dragging-line * { cursor: grabbing !important; }

/* the chalk ledge: tin tiles and the run plate */
.dock { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; padding: .55rem .55rem .35rem; padding-left: max(.55rem, env(safe-area-inset-left)); padding-right: max(.55rem, env(safe-area-inset-right));
  background: linear-gradient(#8a5f38, var(--wood) 30%, var(--wood-dark)); box-shadow: 0 -3px 0 rgba(0, 0, 0, .35); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.tiles[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile { min-height: 3rem; padding: 0 .1rem; font-weight: 700; font-size: .84rem; letter-spacing: .02em; white-space: nowrap; color: var(--ink);
  background: linear-gradient(#f2eddf, var(--tin)); border: 2px solid var(--ink); border-left: .55rem solid var(--teal); border-radius: 4px; box-shadow: 0 3px 0 var(--ink); }
.tile.tREP, .tile.tIF { border-left-color: #3f8fb5; } .tile.tH { border-left-color: #d0432e; }
.tile:active, .run:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.run { width: 5rem; min-height: 3rem; padding: 0; font-family: var(--title); font-size: 1.7rem; color: var(--ink); background: linear-gradient(#f8de7c, var(--yellow)); border: 2px solid var(--ink); border-radius: 4px; box-shadow: 0 3px 0 var(--ink); }
.run.going { background: #f08a6b; }
/* STEP: a chalked plate under RUN, one tick a press */
.go { display: flex; flex-direction: column; gap: .4rem; }
.step { width: 5rem; min-height: 2.75rem; padding: 0; display: flex; align-items: center; justify-content: center; gap: .3rem; font-family: var(--title); font-size: 1.15rem; color: var(--yellow);
  background: var(--slate); border: 2px solid var(--chalk); border-radius: 4px; box-shadow: 0 3px 0 var(--ink); }
.step .glyph { font-family: var(--body); font-weight: 700; font-size: .85rem; letter-spacing: -.1em; }
.step.on { background: #3a454b; border-color: var(--yellow); box-shadow: 0 3px 0 var(--ink), inset 0 0 0 2px rgba(244, 211, 94, .35); }
.step:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.ln .pass { margin-left: .2rem; padding: 0 .4rem; font-family: var(--hand); font-size: .95rem; line-height: 1.5; letter-spacing: 0; color: var(--yellow); border: 2px dashed rgba(244, 211, 94, .7); border-radius: 1rem; }
.hint { animation: hint 1s ease-in-out infinite; }
@keyframes hint { 0%, 100% { outline: 3px solid rgba(255, 255, 255, .95); outline-offset: 2px; } 50% { outline: 3px solid rgba(255, 255, 255, .95); outline-offset: 7px; } }
.foot { display: flex; align-items: baseline; gap: .4rem; padding: 0 .6rem max(.3rem, env(safe-area-inset-bottom)); background: var(--wood-dark); color: #e6d6bd; font-size: .68rem; white-space: nowrap; overflow: hidden; }
.foot h1 { margin: 0; font-family: var(--title); font-weight: 400; font-size: .85rem; }
.foot .line { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#buildstamp { font-family: ui-monospace, monospace; font-size: .62rem; color: #cdb99b; }

/* the track list */
.levels { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: .6rem; background: rgba(15, 18, 20, .8); }
.sheet { width: min(100%, 40rem); max-height: 100%; overflow-y: auto; padding: 1rem 1rem .9rem; background: var(--slate); border: .5rem solid var(--wood); border-radius: 4px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5); }
.sheet h2 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 2.2rem; line-height: 1; }
.sum { margin: .3rem 0 .8rem; font-size: .9rem; color: var(--dim); }
.list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.lv { width: 100%; min-height: 3.4rem; display: grid; grid-template-columns: 2rem minmax(0, 1fr); grid-template-rows: auto auto; column-gap: .5rem; align-items: center; padding: .3rem .5rem; text-align: left;
  background: var(--slate-deep); border: 2px dashed rgba(239, 234, 221, .45); border-radius: 4px; }
.lv .no { grid-row: 1 / 3; font-family: var(--title); font-size: 1.8rem; color: var(--yellow); text-align: center; }
.lv .nm { font-family: var(--hand); font-size: 1rem; line-height: 1.1; overflow-wrap: anywhere; }
.lv .st { font-size: .95rem; letter-spacing: .1em; color: #59646a; } .lv .st i { font-style: normal; } .lv .st .on { color: var(--yellow); }
.lv .bs { display: none; }
.lv.here { border-style: solid; border-color: var(--yellow); }
.lv:disabled { cursor: default; border-color: rgba(239, 234, 221, .15); } .lv:disabled .no, .lv:disabled .nm { color: #7c868a; }
.dailybox { margin: 0 0 .6rem; }
.lv.day { grid-template-rows: auto auto auto; border-color: var(--blue); background: linear-gradient(100deg, rgba(155, 211, 236, .12), transparent 70%), var(--slate-deep); }
.lv.day .no { grid-row: 1 / 4; color: var(--blue); }
.lv.day .nm { font-family: var(--title); font-size: 1.15rem; }
.lv.day .dt { font-family: var(--hand); font-size: .95rem; color: var(--yellow); overflow-wrap: anywhere; }
.lv.day.here { border-color: var(--yellow); }
.lv.day .bs { display: block; grid-column: 2; font-size: .75rem; color: var(--dim); }
.past { margin: .5rem 0 0; }
.pastH { margin: 0 0 .3rem; font-family: var(--hand); font-size: .95rem; color: var(--dim); }
.pastL { display: flex; flex-wrap: wrap; gap: .4rem; max-height: 9.5rem; overflow-y: auto; }
.pd { min-width: 4.4rem; min-height: 2.75rem; padding: .2rem .45rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; background: var(--slate-deep); color: var(--chalk); border: 2px dashed rgba(155, 211, 236, .45); border-radius: 4px; font-family: var(--hand); font-size: .95rem; }
.pd.here { border-color: var(--yellow); border-style: solid; }
.pd .st { font-size: .7rem; letter-spacing: .05em; color: rgba(239, 234, 221, .25); } .pd .st .on { color: var(--yellow); }
.chip.daily .no { color: var(--blue); }
.sheet .row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.sheet .row button { flex: 1 1 12rem; min-height: 2.75rem; padding: .3rem .8rem; border-radius: 4px; font-size: .95rem; }
.door { background: none; border: 2px solid var(--blue); color: var(--blue); }
.close { background: var(--yellow); border: 2px solid var(--ink); color: var(--ink); font-weight: 700; box-shadow: 0 3px 0 var(--ink); }

/* desktop and landscape: the track beside the slate */
@media (min-width: 760px) and (min-aspect-ratio: 11/10) {
  #app { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) minmax(22rem, 27rem); }
  #slate { border-top: 0; border-left: .6rem solid var(--wood); box-shadow: inset 8px 0 10px -6px rgba(0, 0, 0, .5); }
  #say { padding-right: 3.4rem; font-size: 1.25rem; }
  .head { padding-top: .8rem; }
  .list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile { font-size: .95rem; } .run, .step { width: 5.6rem; }
  .lv .bs { display: block; grid-column: 2; font-size: .75rem; color: var(--dim); }
  .lv { grid-template-rows: auto auto auto; } .lv .no { grid-row: 1 / 4; }
}
@media (max-height: 560px) and (max-aspect-ratio: 11/10) { .marlene { display: none; } .foot .line { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .hint, .tab:hover svg, .tab.cue svg, .card, .card .stars .on, #say.new, .prog.full, .caret .cur { animation: none; }
  .hint { outline: 3px solid #fff; outline-offset: 3px; }
}
