/* Fonts are self-hosted (fonts/, SIL Open Font License): no requests to Google, works offline. */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/hanken-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/hanken-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/hanken-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/hanken-grotesk-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/newsreader-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/newsreader-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Andika"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/andika-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Andika"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/andika-latin-700-normal.woff2") format("woff2"); }

/* Layout: one calm column, a hairline-framed spine across the middle, everything else quiet around it. */
:root {
  --bg: #ecebe8;          /* outside the app on wide screens */
  --paper: #fbfbf9;       /* app surface */
  --ink: #17181b;
  --muted: #8b8c90;
  --faint: #b9bab9;
  --line: #e4e4e0;
  --soft: #f1f1ed;
  --hl: #f4e6ae;          /* the one highlight: selection */
  --hl-soft: rgba(244, 230, 174, .38);
  --ok: #d3ead9;
  --bad: #f5d6cf;
  --good: #2f7a4f;
  --alert: #c0412b;
  --k0: #ffd9cf; --k1: #ffeaa6; --k2: #cdeed8; --k3: #d3e6ff; --k4: #e6dcff; --star: #f0b400;  /* kids column colours */
  --shadow: rgba(20, 20, 25, .10);

  --sans: "Hanken Grotesk", -apple-system, "Helvetica Neue", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --p: 36px;              /* tile pitch, set per board from JS */
  --spring: cubic-bezier(.34, 1.42, .5, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090a; --paper: #131416; --ink: #ecebe6; --muted: #8d8e92; --faint: #55575b;
    --line: #26282b; --soft: #1c1d20; --hl: #5a4d21; --hl-soft: rgba(120, 103, 44, .30);
    --ok: #1f3e2b; --bad: #4b2520; --good: #86c99f; --alert: #f08a74; --shadow: rgba(0, 0, 0, .5);
    --k0: #5b3027; --k1: #574617; --k2: #21452f; --k3: #213a58; --k4: #3a2f5c; --star: #ffcf40;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09090a; --paper: #131416; --ink: #ecebe6; --muted: #8d8e92; --faint: #55575b;
  --line: #26282b; --soft: #1c1d20; --hl: #5a4d21; --hl-soft: rgba(120, 103, 44, .30);
  --ok: #1f3e2b; --bad: #4b2520; --good: #86c99f; --alert: #f08a74; --shadow: rgba(0, 0, 0, .5);
    --k0: #5b3027; --k1: #574617; --k2: #21452f; --k3: #213a58; --k4: #3a2f5c; --star: #ffcf40;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: var(--ink); }
button:focus-visible, .hit:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* App shell: full screen on phones, a centred column on desktop */
#app {
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
@media (min-width: 520px) {
  #app { box-shadow: 0 0 0 1px var(--line), 0 24px 60px var(--shadow); }
}
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
[hidden] { display: none !important; }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 4px; flex: none; }
.ic { background: none; border: 0; font-size: 18px; width: 44px; height: 32px; text-align: left; cursor: pointer; padding: 0; color: var(--muted); }
.brand { font-weight: 700; letter-spacing: .42em; font-size: 13px; padding-left: .42em; }
.timer { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); width: 44px; text-align: right; }
.meta { display: flex; justify-content: space-between; align-items: center; padding: 6px 18px 0; font-size: 12px; color: var(--muted); flex: none; }
.chip { letter-spacing: .08em; text-transform: uppercase; font-size: 11px; font-weight: 600; color: var(--muted); }
.spine { margin: 14px 18px 0; padding: 0 0 0 12px; border-left: 2px solid var(--ink); font-family: var(--serif); font-size: 17px; line-height: 1.35; display: flex; flex-direction: column; gap: 2px; flex: none; }
.spine .lbl { font-family: var(--sans); font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.len { color: var(--faint); font-family: var(--sans); font-size: .8em; font-variant-numeric: tabular-nums; }

/* Board */
.board {
  flex: 1;
  min-height: 150px;
  position: relative;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent 0, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(transparent 0, #000 18%, #000 82%, transparent);
}
.grid { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); }
.rowbox {
  position: absolute; left: 0; top: 50%;
  height: var(--p); margin-top: calc(var(--p) / -2);
  display: flex; border-radius: 5px; overflow: hidden;
  box-shadow: 0 0 0 1.5px var(--ink); transition: background .5s ease;
}
.cell { width: var(--p); height: var(--p); border-right: 1px solid var(--line); position: relative; transition: background .25s ease; }
.cell:last-child { border-right: 0; }
.cell .no { position: absolute; top: 3px; left: 4px; font-size: 9px; color: var(--faint); font-variant-numeric: tabular-nums; }
.cell.sel { background: var(--hl); }
.cell.ok { background: var(--ok); }
.cell.bad { background: var(--bad); }

/* Columns move on a spring; letters fade and shrink away from the spine (set inline from JS). */
.col { position: absolute; top: 50%; margin-top: calc(var(--p) / -2); width: var(--p); transition: transform .38s var(--spring); pointer-events: none; will-change: transform; }
.t {
  height: var(--p); display: grid; place-items: center;
  font-size: calc(var(--p) * .5); font-weight: 450;
  transition: opacity .3s ease, transform .38s var(--spring), color .3s ease;
}
.t.inrow { font-weight: 700; }
.col.dragging, .col.dragging .t { transition: none; }
.selcol::before { content: ""; position: absolute; inset: 0; background: var(--hl-soft); border-radius: 4px; z-index: -1; }
.col.drop .t { animation: drop .5s var(--spring) backwards; }
@keyframes drop { from { opacity: 0; transform: translateY(calc(var(--p) * -.8)) scale(.85); } }
.hit { position: absolute; top: 0; bottom: 0; width: var(--p); z-index: 5; cursor: pointer; touch-action: none; }
.hit.grab { cursor: grab; }
.hit.grab:active { cursor: grabbing; }
.board.won .cell { background: var(--ink); }
.board.won .cell { border-color: transparent; }
.board.won .cell.locked::after { display: none; }
.board.won .t.inrow { color: var(--paper); }

/* Bottom panel */
.panel { height: 300px; flex: none; border-top: 1px solid var(--line); padding: 16px 14px max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.clue { display: flex; gap: 10px; align-items: baseline; padding: 0 4px; }
.num { min-width: 18px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.ctext { flex: 1; font-family: var(--serif); font-size: 19px; line-height: 1.3; }
.x { background: none; border: 0; font-size: 22px; color: var(--faint); cursor: pointer; line-height: 1; padding: 0 4px; }
.slots { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.slot { width: 22px; height: 32px; border-bottom: 1.5px solid var(--line); display: grid; place-items: center; font-weight: 600; font-size: 17px; transition: border-color .2s; }
.slot.cur { border-color: var(--ink); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.kb { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.kr { display: flex; gap: 5px; justify-content: center; }
.k { flex: 1; max-width: 36px; height: 46px; border: 0; border-radius: 8px; background: var(--soft); font-size: 15px; font-weight: 500; cursor: pointer; padding: 0; touch-action: manipulation; transition: background .12s, transform .12s; }
.k.wide { max-width: 54px; font-size: 12px; }
.k:active { background: var(--line); transform: scale(.94); }
.phead { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; padding: 0 4px; }
.list { overflow: auto; display: flex; flex-direction: column; margin: 0 -2px; scrollbar-width: none; -ms-overflow-style: none; overscroll-behavior: contain; }
.list::-webkit-scrollbar { display: none; }
.list.more { -webkit-mask-image: linear-gradient(#000 calc(100% - 36px), transparent); mask-image: linear-gradient(#000 calc(100% - 36px), transparent); }
.li { display: flex; gap: 10px; align-items: baseline; padding: 7px 6px; border-radius: 8px; cursor: pointer; line-height: 1.3; background: none; border: 0; text-align: left; width: 100%; }
.li:hover { background: var(--soft); }
.li .txt { flex: 1; font-family: var(--serif); font-size: 16px; }
.li.done .txt { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 1px; }
.li.done .num { color: var(--faint); }
.solvedline { font-size: 14px; font-weight: 700; letter-spacing: .2em; color: var(--good); padding-left: 32px; }
.slidehelp { font-size: 14px; color: var(--muted); line-height: 1.45; padding-left: 32px; }
.btns { display: flex; gap: 8px; margin-top: auto; }
.btn { height: 48px; min-width: 58px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-size: 15px; font-weight: 600; cursor: pointer; touch-action: manipulation; transition: background .15s, transform .12s; }
.btn:active { transform: scale(.97); }
.btn:hover:not(:disabled) { background: var(--soft); }
.btn.wide { flex: 1; }
.btn.dark { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.dark:hover { background: var(--ink); opacity: .9; }
.btn:disabled { opacity: .35; cursor: default; }

/* Bottom sheet */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--paper); border-radius: 24px 24px 0 0; box-shadow: 0 -16px 50px var(--shadow);
  padding: 12px 22px max(28px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; animation: up .55s var(--spring) .25s backwards; z-index: 10;
}
@keyframes up { from { transform: translateY(100%); } }
.handle { width: 36px; height: 4px; border-radius: 9px; background: var(--line); margin: 0 auto 6px; }
.sheet .kick { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); text-align: center; font-weight: 600; }
.sheet .big { font-size: 28px; font-weight: 700; letter-spacing: .24em; text-align: center; padding-left: .24em; }
.sheet .legend { text-align: center; font-size: 12px; color: var(--muted); margin-top: -4px; }
.sheet .sub { text-align: center; color: var(--muted); font-size: 14px; }
.share { background: var(--soft); border-radius: 12px; padding: 12px 14px; font: 13px/1.6 ui-monospace, Menlo, monospace; white-space: pre; margin: 0; overflow-x: auto; user-select: text; -webkit-user-select: text; }

/* Home, how-to, archive, stats */
.home > * { flex-shrink: 0; }
.home { flex: 1; padding: 22px 20px max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.logo { display: flex; align-self: center; box-shadow: 0 0 0 1.5px var(--ink); border-radius: 5px; overflow: hidden; margin: 22px 0 6px; }
.logo div { width: 38px; height: 38px; display: grid; place-items: center; font-weight: 700; font-size: 18px; border-right: 1px solid var(--line); }
.logo div:last-child { border-right: 0; }
.tag { text-align: center; color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 17px; }
.date { text-align: center; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; font-weight: 600; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--paper); width: 100%; text-align: left; cursor: pointer; font-size: inherit; transition: border-color .2s, transform .15s; }
.card:hover { border-color: var(--faint); }
.card:active { transform: scale(.99); }
.card.main { border-color: var(--ink); }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.go { font-size: 13px; font-weight: 600; white-space: nowrap; }
.go::after { content: " →"; color: var(--muted); }
.go.ghost { color: var(--good); }
.go.ghost::after { content: none; }
.foot { margin-top: auto; display: flex; justify-content: space-around; border-top: 1px solid var(--line); padding-top: 12px; }
.foot button { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px; }
.foot button:hover { color: var(--ink); }
.streak { display: flex; justify-content: center; gap: 32px; font-size: 12px; color: var(--muted); text-align: center; margin-top: 8px; }
.streak b { display: block; font-size: 20px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.step { display: flex; gap: 16px; align-items: flex-start; }
.step .n { font-family: var(--serif); font-size: 32px; line-height: 1; width: 26px; flex: none; color: var(--muted); }
.step h3 { margin: 2px 0 4px; font-size: 16px; font-weight: 600; }
.step p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
.note { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.5; }
.mini { display: flex; margin-top: 10px; }
.mini .c { display: flex; flex-direction: column; width: 26px; }
.mini .c span { height: 26px; display: grid; place-items: center; font-size: 14px; }
.mini .c span.r { box-shadow: 0 0 0 1.5px var(--ink); font-weight: 700; background: var(--paper); }
.mini .c span.y { background: var(--hl-soft); }
.alist { display: flex; flex-direction: column; }
.arow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.aid { font-weight: 600; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; gap: 2px; }
.aid span { font-size: 12px; font-weight: 400; color: var(--muted); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 500; cursor: pointer; }
.pill:hover { border-color: var(--faint); }
.pill.done { color: var(--good); }
.error { margin: auto; padding: 24px; text-align: center; color: var(--muted); line-height: 1.5; }
.error code { background: var(--soft); padding: 2px 6px; border-radius: 4px; color: var(--ink); }
.stats-list { display: flex; flex-direction: column; font-size: 14px; }
.stats-list div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 12px 0; }
.stats-list span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-height: 700px) {
  .panel { height: 270px; }
  .k { height: 40px; }
  .spine { margin-top: 10px; }
}
/* Win: the row fills in left to right and each spine letter hops. */
.board.celebrate .cell { animation: fillin .4s ease backwards; animation-delay: calc(var(--i) * 70ms); }
@keyframes fillin { from { background: transparent; } }
.board.celebrate .t.inrow { animation: hop .55s var(--spring) backwards; animation-delay: calc(var(--i) * 70ms + 120ms); }
@keyframes hop { 0% { color: var(--ink); transform: translateY(0); } 45% { transform: translateY(-9px) scale(1.12); } }

/* Hints, typo nudge, practice tips */
.hintrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 4px; min-height: 20px; }
.msg { font-size: 13px; color: var(--alert); }
.link { background: none; border: 0; padding: 2px 0; font-size: 13px; color: var(--muted); cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.link:hover { color: var(--ink); }
.nohint { font-size: 13px; color: var(--faint); }
.cell.locked::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--muted); }
.tip { margin: 10px 18px 0; padding: 8px 12px; border-radius: 10px; background: var(--soft); font-size: 13px; line-height: 1.4; color: var(--ink); flex: none; }
.card.practice { border-style: dashed; }
.next { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.next span { font-variant-numeric: tabular-nums; color: var(--ink); }

/* Timer: hidden by setting */
[data-notimer] .timer { visibility: hidden; }

/* Kids: same layout, softer and more colourful. Andika is a typeface made for children learning to read. */
#app[data-kids] { font-family: "Andika", var(--sans); }
#app[data-kids] .spine, #app[data-kids] .ctext, #app[data-kids] .li .txt { font-family: "Andika", var(--sans); }
#app[data-kids] .t, #app[data-kids] .slot, #app[data-kids] .k, #app[data-kids] .sheet .big { text-transform: lowercase; }
#app[data-kids] .rowbox { border-radius: 12px; box-shadow: 0 0 0 3px var(--ink); }
#app[data-kids] .cell { border-right-color: transparent; }
#app[data-kids] .cell.sel { background: var(--c); }
#app[data-kids] .cell .kpic { inset: 0; top: 0; left: 0; display: grid; place-items: center; font-size: calc(var(--p) * .44); color: inherit; opacity: .9; }
#app[data-kids] .t { font-size: calc(var(--p) * .58); font-weight: 600; position: relative; }
#app[data-kids] .t::before { content: ""; position: absolute; inset: 3px; border-radius: 10px; background: var(--c); z-index: -1; }
#app[data-kids] .t.inrow::before { background: transparent; }
#app[data-kids] .selcol::before { background: transparent; box-shadow: 0 0 0 2px var(--ink); border-radius: 12px; inset: 1px; }
#app[data-kids] .cell.ok { background: var(--ok); }
#app[data-kids] .spine { border-left: 0; padding-left: 0; }
#app[data-kids] .stext { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 19px; }
#app[data-kids] .kpic-inline { font-size: 26px; }
#app[data-kids] .tip { background: var(--k1); font-size: 15px; }
#app[data-kids] .k { font-size: 20px; height: 48px; max-width: 40px; border-radius: 12px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line), 0 2px 0 var(--line); }
#app[data-kids] .k:active { transform: translateY(2px) scale(.96); box-shadow: inset 0 0 0 1px var(--line); }
#app[data-kids] .btn { border-radius: 99px; }
#app[data-kids] .li .num { font-size: 20px; min-width: 26px; }
#app[data-kids] .li .txt { font-size: 17px; }
.kclue { align-items: center; }
.kclue .pic { font-size: 34px; line-height: 1; }
.kclue .ctext { font-size: 20px; }
.say { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--soft); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.say:hover { background: var(--line); }
/* Sound buttons: a dot under a one-letter sound, a dash under a two-letter sound (as taught in UK phonics) */
.kslots { gap: 12px; }
.sg { display: flex; flex-direction: column; align-items: center; gap: 7px; background: none; border: 0; padding: 0; font: inherit; color: inherit; }
button.sg { cursor: pointer; border-radius: 10px; padding: 2px 4px 4px; }
button.sg:hover { background: var(--soft); }
.sg .letters { display: flex; gap: 3px; }
.kslots .slot { width: 30px; height: 42px; font-size: 26px; font-weight: 600; }
.kword .slot { border-bottom-color: transparent; }
.sb { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); opacity: .55; }
.sg.dg .sb { width: calc(100% - 10px); height: 5px; border-radius: 4px; }
.kidhints { display: flex; gap: 16px; margin-left: auto; }
#app[data-kids] .panel { height: auto; min-height: 300px; gap: 10px; }
#app[data-kids] .hintrow { flex-wrap: wrap; row-gap: 4px; }
#app[data-kids] .msg:empty { display: none; }
#app[data-kids] .msg { flex-basis: 100%; text-align: center; }
.link { white-space: nowrap; }
.stars { text-align: center; font-size: 34px; letter-spacing: .12em; color: var(--line); }
.stars .on { color: var(--star); }
.card.kidcard { border-color: var(--line); }
.kdots { display: inline-flex; gap: 3px; margin-left: 8px; vertical-align: middle; }
.kdots i { width: 8px; height: 8px; border-radius: 50%; }
.kdots i:nth-child(1) { background: #f39b86; } .kdots i:nth-child(2) { background: #f2c94c; } .kdots i:nth-child(3) { background: #6fcf97; }
.kdots i:nth-child(4) { background: #6ea8fe; } .kdots i:nth-child(5) { background: #b197fc; }
#app[data-kids] .timer { visibility: hidden; }
/* Kids on shorter screens (most phones, and inside app previews): everything tightens so the keyboard stays on screen.
   If a screen is shorter still, the game screen scrolls rather than hiding the keyboard. */
#app[data-kids] #game { overflow-y: auto; }
#app[data-kids] .board { flex: 1 0 auto; min-height: 150px; }
@media (max-height: 760px) {
  #app[data-kids] .top { padding-top: 10px; }
  #app[data-kids] .spine { margin-top: 8px; }
  #app[data-kids] .stext { font-size: 16px; gap: 6px; }
  #app[data-kids] .kpic-inline { font-size: 20px; }
  #app[data-kids] .say { width: 32px; height: 32px; }
  #app[data-kids] .tip { margin-top: 6px; padding: 5px 10px; font-size: 13px; }
  #app[data-kids] .board { min-height: 110px; }
  #app[data-kids] .panel { min-height: 0; padding: 10px 12px max(12px, env(safe-area-inset-bottom)); gap: 8px; }
  #app[data-kids] .kclue .pic { font-size: 26px; }
  #app[data-kids] .kclue .ctext { font-size: 17px; }
  #app[data-kids] .kslots .slot { height: 34px; font-size: 22px; }
  #app[data-kids] .sg { gap: 5px; }
  #app[data-kids] .kb { gap: 5px; }
  #app[data-kids] .k { height: 40px; font-size: 18px; }
}
@media (max-height: 640px) {
  #app[data-kids] .tip { display: none; }
  #app[data-kids] .meta { padding-top: 2px; }
  #app[data-kids] .board { min-height: 96px; }
  #app[data-kids] .k { height: 38px; }
}
/* Kids library: stages, each a row of picture buttons */
.kidshome { font-family: "Andika", var(--sans); gap: 18px; }
.kstage { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.kstage h3 { margin: 0; font-size: 17px; }
.kstage p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.kpuzzles { display: flex; flex-wrap: wrap; gap: 10px; }
.kpuz { position: relative; width: 64px; height: 64px; border-radius: 16px; border: 0; background: var(--k3); font-size: 30px; cursor: pointer; display: grid; place-items: center; transition: transform .15s; }
.kpuz:nth-child(5n+1) { background: var(--k0); } .kpuz:nth-child(5n+2) { background: var(--k1); } .kpuz:nth-child(5n+3) { background: var(--k2); } .kpuz:nth-child(5n+5) { background: var(--k4); }
.kpuz:active { transform: scale(.95); }
.kpuz i { position: absolute; top: -6px; right: -6px; font-style: normal; font-size: 18px; color: var(--star); text-shadow: 0 1px 0 var(--paper); }

/* Settings */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.setting h3 { margin: 0; font-size: 15px; font-weight: 600; }
.setting p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.seg { display: flex; background: var(--soft); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
[data-still] *, [data-still] *::before, [data-still] *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }

/* ---------- Spineword wordmark (logo C): a small sliding column beside a quiet lowercase name ---------- */
.wordmark { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0 2px; font-size: 40px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.wm-mark { display: inline-flex; flex-direction: column; align-items: center; font-weight: 700; letter-spacing: 0; line-height: 1; }
.wm-mark i { font-style: normal; font-weight: 450; font-size: 15px; line-height: 20px; height: 20px; opacity: .32; }
.wm-mark b { width: 34px; height: 34px; display: grid; place-items: center; font-size: 21px; border-radius: 6px; box-shadow: 0 0 0 2px var(--ink); background: var(--hl); color: var(--ink); }
.wm-small { display: inline-flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; padding-left: 0; text-transform: none; }
.wm-small .wm-mark i { display: none; }
.wm-small .wm-mark b { width: 20px; height: 20px; font-size: 12px; border-radius: 4px; box-shadow: 0 0 0 1.5px var(--ink); }
.sheet .legend.ok { color: var(--good); }

/* ---------- Leagues page ---------- */
.lg { gap: 16px; }
.lg-box { display: flex; flex-direction: column; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.lg-box:last-child { border-bottom: 0; }
.lg-box h2 { margin: 0; font-size: 17px; font-weight: 600; }
.lg-box .streak { justify-content: flex-start; margin-top: 0; }
.lg-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.lg-row .btn { height: 42px; padding: 0 16px; font-size: 14px; }
.lg-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; min-width: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.lg-field input { font: inherit; font-size: 16px; font-weight: 400; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0; user-select: text; -webkit-user-select: text; }
.lg-field input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.lg-msg { margin: 0; font-size: 13px; color: var(--good); min-height: 0; }
.lg-msg:empty { display: none; }
.lg-msg.err { color: var(--alert); }
.lg-actions { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.lg-confirm { color: var(--alert); font-size: 13px; }
.link.danger { color: var(--alert); }
.lg .seg { align-self: flex-start; flex-wrap: wrap; }
.lg-table { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.lg-table h3 { margin: 0; font-size: 14px; font-weight: 600; }
.lg-table table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.lg-table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.lg-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.lg-table .num { text-align: right; width: 2.6em; }
.lg-table .nm { overflow-wrap: anywhere; }
.lg-table .pts { font-weight: 600; }
.lg-table tr.you td { background: var(--hl-soft); }
.lg-table tr.gap td, .lg-table .empty { text-align: center; color: var(--muted); }
.lg-table .wins { font-size: 11px; color: var(--muted); }
.lg-more { align-self: flex-start; }
.lg-league-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: -2px; }
.lg-league-bar b { color: var(--ink); letter-spacing: .08em; }
.lg-hl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lg-hl:empty { display: none; }
.lg-hl-tile { background: var(--soft); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lg-hl-tile span { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.lg-hl-tile b { font-size: 14px; overflow-wrap: anywhere; }
.lg-hl-tile small { font-size: 12px; color: var(--muted); }
.lg-hl-tile.you { box-shadow: inset 0 0 0 1.5px var(--ink); }
.medal { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; }
.medal.m1 { background: #d9a400; } .medal.m2 { background: #a7adb4; } .medal.m3 { background: #b8743c; }
.lg-medals { display: flex; gap: 18px; font-size: 15px; }
.lg-medals span { display: inline-flex; align-items: center; gap: 6px; }
.lg-awards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; font-size: 13px; }
.lg-awards li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.lg-awards li span { flex: 1; min-width: 0; color: var(--muted); }
.lg-sub { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.lg-badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.lg-badges li { display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 10px; align-items: center; padding: 8px; border-radius: 10px; border: 1px solid var(--line); opacity: .55; }
.lg-badges li.got { opacity: 1; border-color: var(--ink); }
.lg-badges .bm { grid-row: span 2; width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 700; box-shadow: 0 0 0 1.5px var(--ink); }
.lg-badges li.got .bm { background: var(--hl); color: var(--ink); }
.lg-badges b { font-size: 13px; }
.lg-badges small { font-size: 11px; color: var(--muted); line-height: 1.3; }
@media (max-width: 380px) { .lg-table .hide-sm { display: none; } .lg-badges { grid-template-columns: minmax(0, 1fr); } }

/* Privacy page */
.prose-page { background: var(--bg); }
.prose { max-width: 640px; margin: 0 auto; background: var(--paper); min-height: 100%; padding-block: 28px 48px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); font-size: 16px; line-height: 1.6; }
.prose h1 { font-size: 28px; margin: 18px 0 8px; }
.prose h2 { font-size: 18px; margin: 24px 0 6px; }
.prose a { color: var(--ink); }
.prose a.wm-small { text-decoration: none; }

/* Bottom of Settings: privacy, and the (login-protected) setter for the puzzle editor */
.site-foot { margin: auto 0 0; padding-top: 18px; display: flex; gap: 18px; justify-content: center; font-size: 12px; }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a.quiet { color: var(--faint); }
.site-foot a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Rounded look (chosen 6 Nov: "A2's card with A3's tiles") ----------
   Letters sit on soft rounded chips, each word tinted its own muted colour; white raised keys;
   softly filled cards; the Daily card is pale yellow with today's spine as a row of empty boxes. */
:root {
  --t0: #f1e2db; --t1: #f1eacd; --t2: #dceade; --t3: #dde6f1; --t4: #e7e1f0;   /* word tints */
  --card: #f3f2ee; --key: #ffffff; --key-edge: #d6d5cf;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --t0: #3b2c27; --t1: #39331f; --t2: #233329; --t3: #222d3a; --t4: #2e293a; --card: #1c1d20; --key: #232427; --key-edge: #0e0f10; }
}
:root[data-theme="dark"] { --t0: #3b2c27; --t1: #39331f; --t2: #233329; --t3: #222d3a; --t4: #2e293a; --card: #1c1d20; --key: #232427; --key-edge: #0e0f10; }

.rowbox { border-radius: 12px; box-shadow: 0 0 0 2px var(--ink); }
.t { position: relative; }
.t::before { content: ""; position: absolute; inset: 3px; border-radius: 10px; background: var(--c, var(--card)); z-index: -1; }
.t.inrow::before { background: transparent; }
.board.won .t::before { opacity: .55; }
.spine { border-left: 0; padding: 10px 14px; border-radius: 14px; background: var(--card); margin-top: 12px; }
.k { background: var(--key); border-radius: 11px; box-shadow: 0 1px 0 var(--key-edge), 0 0 0 1px var(--line); }
.k:active { background: var(--soft); transform: translateY(1px) scale(.97); box-shadow: 0 0 0 1px var(--line); }
.card { border: 1px solid transparent; border-radius: 20px; background: var(--card); }
.card:hover { border-color: var(--line); }
.card.main { border: 1.5px solid var(--ink); background: var(--hl); }
.card.main p { color: var(--ink); opacity: .72; }
.card.main .go { background: var(--paper); color: var(--ink); padding: 7px 14px; border-radius: 99px; box-shadow: 0 0 0 1.5px var(--ink); }
.card.main .go::after { color: var(--ink); }
.card.main .go.ghost { color: var(--good); }
.card.practice { border: 1.5px dashed var(--line); background: transparent; }
.wm-mark b { border-radius: 10px; }
.wm-small .wm-mark b { border-radius: 6px; }
.btn { border-radius: 14px; }
/* Today's spine on the Daily card: one empty box per letter (its length only, no letters) */
.trow { display: inline-flex; margin-top: 10px; border-radius: 5px; overflow: hidden; box-shadow: 0 0 0 1.5px var(--ink); }
.trow:empty { display: none; }
.trow i { display: block; width: 15px; height: 15px; background: var(--paper); border-right: 1px solid var(--line); }
.trow i:last-child { border-right: 0; }
