/* Cryptic Mini: "Midnight Candy" brand. Light and dark themes share the four candy accents.
   Default follows the visitor's system setting; the header toggle stores an override
   in localStorage ("cm-theme") which sets data-theme on <html>. */
:root{
  --pink:#E0559A;--mint:#14A394;--lemon:#FFD166;--lilac:#7B68EE;
  --bg:#FBF8FF;--surface:#FFFFFF;--surface2:#F1EAFF;--ink:#241B35;--muted:#6B6185;--line:#E4DCF2;
  --accent:#7B68EE;--hdr:#241B35;--hdr-ink:#F5F0FF;
  --cell:#FFFFFF;--block:#0B0816;--gridline:#0B0816;--word:#E3DAFF;--sel:#FFD166;--sel-ink:#241B35;
  --wrong:#E0559A;--rev:#14A394;--btn:#FFFFFF;--btn-line:#D9CFEF;--hint:#F1EAFF;--hint-ink:#4A3C8C;--ex:#E3F7F3;--ex-ink:#155E57;
  --lede:#544A6E;--cell-ink:#241B35;--cell-wrong:#E0559A;--cell-rev:#14A394;--clue-cur:#E3DAFF;
  --cs:48px;
}
/* The grid uses the light colours in both themes; only the page around it goes dark. */
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --pink:#FF7AB6;--mint:#7CE0D3;--lemon:#FFD166;--lilac:#9D8CFF;
  --bg:#1B1530;--surface:#251D40;--surface2:#2F2652;--ink:#F5F0FF;--muted:#B3A8D6;--line:#3A3060;
  --accent:#7CE0D3;--hdr:#140F26;--hdr-ink:#F5F0FF;
  --clue-cur:#4A3C8C;--lede:#C9BFEA;
  --wrong:#FF7AB6;--rev:#7CE0D3;--btn:#2F2652;--btn-line:#4A3F78;--hint:#2F2652;--hint-ink:#D8CFFF;--ex:#1F3A43;--ex-ink:#BFF3EC;
}}
:root[data-theme="dark"]{
  --pink:#FF7AB6;--mint:#7CE0D3;--lemon:#FFD166;--lilac:#9D8CFF;
  --bg:#1B1530;--surface:#251D40;--surface2:#2F2652;--ink:#F5F0FF;--muted:#B3A8D6;--line:#3A3060;
  --accent:#7CE0D3;--hdr:#140F26;--hdr-ink:#F5F0FF;
  --clue-cur:#4A3C8C;--lede:#C9BFEA;
  --wrong:#FF7AB6;--rev:#7CE0D3;--btn:#2F2652;--btn-line:#4A3F78;--hint:#2F2652;--hint-ink:#D8CFFF;--ex:#1F3A43;--ex-ink:#BFF3EC;
}
*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{margin:0}
body{font:16px/1.5 system-ui,"Segoe UI",Roboto,sans-serif;background:var(--bg);color:var(--ink);transition:background .2s,color .2s}
a{color:var(--accent)}

/* header + tile logo */
header.site{display:flex;align-items:center;gap:22px;flex-wrap:wrap;padding:12px 20px;background:var(--hdr)}
header.site .brand{display:inline-flex;gap:3px;text-decoration:none}
.brand .t{width:26px;height:26px;border-radius:6px;display:inline-flex;align-items:center;justify-content:center;font:800 15px system-ui,sans-serif;color:#1B1530}
.brand .t0{background:#FF7AB6}.brand .t1{background:#7CE0D3}.brand .t2{background:#FFD166}.brand .t3{background:#9D8CFF}
.brand .gap{width:8px}
header.site nav{display:flex;gap:18px}
header.site nav a{color:var(--hdr-ink);opacity:.8;text-decoration:none;font-size:15px;font-weight:600}
header.site nav a:hover{opacity:1}
.theme-toggle{margin-left:auto;font:18px system-ui,sans-serif;line-height:1;background:transparent;border:1px solid #ffffff33;color:var(--hdr-ink);border-radius:9px;padding:6px 9px;cursor:pointer}
.theme-toggle:hover{border-color:#ffffff88}
footer.site{text-align:center;color:var(--muted);font-size:13px;max-width:1060px;margin:20px auto 0;padding:12px 16px 22px;border-top:1px solid var(--line)}

main{max-width:1100px;margin:0 auto;padding:20px}
main.text{max-width:760px}
h1{font:800 28px system-ui,"Segoe UI",sans-serif;letter-spacing:-.3px;margin:6px 0}
h2{font:800 20px system-ui,"Segoe UI",sans-serif;margin:18px 0 8px}
h3{font:700 17px system-ui,"Segoe UI",sans-serif;margin:16px 0 6px}
.ph .date{color:var(--muted);margin:0}
.lede{margin:28px 0 0;max-width:640px;color:var(--lede)}

/* toolbar + buttons */
.toolbar{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:16px 0 10px}
.grp{display:inline-flex;gap:4px;align-items:center;font-size:13px;color:var(--muted)}
.grp button,.helprow button,button.share{font:inherit;font-size:13px;font-weight:600;border:1px solid var(--btn-line);background:var(--btn);color:var(--ink);padding:6px 11px;border-radius:10px;cursor:pointer}
.grp button:hover,.helprow button:hover{border-color:var(--lilac)}
.sp{flex:1}
.timer{font:700 16px ui-monospace,Consolas,monospace;color:var(--ink)}
.msg{padding:11px 14px;border-radius:12px;margin-bottom:12px;background:var(--surface2);border:1px solid var(--line);border-left:5px solid var(--lemon);display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.msg.good{border-left-color:var(--mint)}
button.share{background:var(--pink);border-color:var(--pink);color:#1B1530}

/* layout */
.layout{display:flex;gap:28px;flex-wrap:wrap;align-items:flex-start}
.gridcol{flex:0 0 auto;min-width:0}
.clues{flex:1 1 340px;display:grid;grid-template-columns:1fr 1fr;gap:18px}
.cur{background:var(--surface2);border-radius:12px;padding:10px 12px;margin-bottom:10px;min-height:46px;width:0;min-width:100%}
.cur .en,.clues .en{color:var(--muted);white-space:nowrap}
.hinttext{font-size:14px;margin-top:5px;color:var(--hint-ink)}
.helprow{display:flex;gap:6px;margin-top:8px}

/* grid */
.grid{display:grid;gap:2px;background:var(--gridline);border:3px solid var(--gridline);border-radius:10px;overflow:hidden;width:max-content;user-select:none;-webkit-user-select:none;touch-action:manipulation;cursor:pointer}
.grid.solved{border-color:var(--rev);background:var(--rev)}
.cell{position:relative;width:var(--cs);height:var(--cs);background:var(--cell);color:var(--cell-ink)}
.cell .num{position:absolute;top:2px;left:4px;font-size:calc(var(--cs)*.25);line-height:1;pointer-events:none;opacity:.75}
.cell .let{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:calc(var(--cs)*.55);font-weight:700;padding-top:calc(var(--cs)*.1);pointer-events:none}
.cell.block{background:var(--block)}
.cell.word{background:var(--word)}
.cell.sel{background:var(--sel);color:var(--sel-ink)}
.cell.wrong{background-image:linear-gradient(to top right,transparent calc(50% - 1px),var(--cell-wrong) 50%,transparent calc(50% + 1px))}
.cell.wrong .let{color:var(--cell-wrong)}
.cell.revealed .let{color:var(--cell-rev)}
.cell.sel.revealed .let,.cell.sel.wrong .let{color:var(--sel-ink)}
.cell.br::before{content:'';position:absolute;top:-2px;bottom:-2px;right:-4px;width:5px;background:var(--gridline);z-index:2}
.cell.bb::after{content:'';position:absolute;left:-2px;right:-2px;bottom:-4px;height:5px;background:var(--gridline);z-index:2}
.cell.hr::before{content:'';position:absolute;top:calc(50% - 1px);right:-6px;width:10px;height:3px;background:var(--gridline);z-index:2}
.cell.hb::after{content:'';position:absolute;left:calc(50% - 1px);bottom:-6px;height:10px;width:3px;background:var(--gridline);z-index:2}

/* clue lists */
.clues ol{list-style:none;margin:0;padding:0}
.clues li{display:grid;grid-template-columns:28px 1fr;padding:6px 8px;border-radius:9px;cursor:pointer;border-left:3px solid transparent}
.clues li:hover{background:var(--surface2)}
.clues li.cur{background:var(--clue-cur)}
.clues li.cross{border-left-color:var(--lilac)}
.clues li.filled .t{color:var(--muted)}
.clues li.cur .t{color:var(--ink)}
.clues li.cur .en{color:var(--ink);opacity:.75}
.clues li .n{font-weight:800}
.clues li .hn{grid-column:2;font-size:13px;color:var(--hint-ink);background:var(--hint);border-radius:7px;padding:4px 8px;margin-top:4px}
.clues li .ex{grid-column:2;font-size:13px;color:var(--ex-ink);background:var(--ex);border-radius:7px;padding:4px 8px;margin-top:4px}
.clues li .ex,.clues li .hn{white-space:pre-line}
.noclue{color:var(--muted);font-style:italic}
.prevnext{display:flex;justify-content:space-between;margin:24px 0 0}

/* archive + content pages */
ol.archive{list-style:none;padding:0}
ol.archive li{display:flex;justify-content:space-between;gap:12px;padding:12px 16px;background:var(--surface);border:1px solid var(--line);border-radius:12px;margin-bottom:8px}
ol.archive .num{color:var(--muted);margin-right:6px}
ol.archive .status{color:var(--rev);font-size:14px;font-weight:600}
.example{background:var(--surface);border:1px solid var(--line);border-left:5px solid var(--pink);border-radius:12px;padding:10px 14px;margin:10px 0}
table.abbr{border-collapse:collapse;width:100%;background:var(--surface);border-radius:12px;overflow:hidden}
table.abbr td,table.abbr th{border:1px solid var(--line);padding:7px 11px;text-align:left;font-size:15px}
table.abbr th{background:var(--surface2)}
#kbd{position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;font-size:16px;border:0;padding:0}
@media (max-width:700px){
  .clues{grid-template-columns:1fr}main{padding:14px}
  .ph h1{font-size:22px}
  .toolbar{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;gap:8px;padding-bottom:4px;margin-top:10px}
  .toolbar .grp{flex:none}
  header.site{gap:14px;padding:10px 14px}
  header.site nav{gap:12px}
  .brand .t{width:22px;height:22px;font-size:13px;border-radius:5px}
}

/* phones and tablets: built-in keyboard + clue bar instead of the system keyboard */
.mkb{position:fixed;left:0;right:0;bottom:0;z-index:30;background:var(--surface2);border-top:1px solid var(--line);
  padding:6px 4px calc(6px + env(safe-area-inset-bottom));box-shadow:0 -6px 24px #0003;
  touch-action:manipulation;user-select:none;-webkit-user-select:none}
body:not(.kb-on) .mkb{display:none}
body.kb-on{padding-bottom:calc(252px + env(safe-area-inset-bottom))}
.mclue{display:flex;align-items:center;gap:2px;background:var(--clue-cur);border-radius:12px;margin:0 2px 6px;min-height:54px}
.mtext{flex:1;padding:8px 4px;font-size:16px;line-height:1.3;color:var(--ink)}
.mtext .en{color:var(--muted)}
.mnav{flex:none;width:44px;align-self:stretch;border:0;background:transparent;color:var(--ink);font:700 30px system-ui,sans-serif;cursor:pointer;padding:0}
.mrow{display:flex;justify-content:center;gap:5px;margin:0 0 7px}
.mkey{flex:1;max-width:44px;height:46px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--ink);
  font:700 19px system-ui,sans-serif;padding:0;box-shadow:0 1px 0 #0002;cursor:pointer}
.mkey.del{flex:1.6;max-width:70px;font-size:20px}
.mkey:active{background:var(--lemon);color:#1B1530}
body.touchui .cur .curline{display:none}
body.touchui .cur{min-height:0}
