/* Word Search: night-teal paper with soft highlighter strokes.
   Board looks (cosmetics) set body[data-look]; each look sets the same tokens. */
:root{
  --bg:#0c2427; --bg2:#0f2e32; --paper:#133a3e; --paper-edge:#1d4c51; --letter:#f3ead6; --letter-dim:rgba(243,234,214,.32);
  --ui:#f3ead6; --ui-muted:#b9cbc6; --line:rgba(243,234,214,.14); --chip:#123438; --accent:#5fe3b3; --accent-ink:#06201a; --warn:#ff8f7a;
  --hl-a:.42; --blend:normal;
  --h0:#5fe3b3; --h1:#ff8f7a; --h2:#ffd36b; --h3:#7cc4ff; --h4:#c7a3ff; --h5:#ff9ccf; --h6:#c6f06b; --h7:#ffb26b;
  --font:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --letters:ui-rounded,"SF Pro Rounded","Arial Rounded MT Bold",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --cell:32px; --pad:8px;
}
@media (max-width:520px){ :root{ --pad:4px; } }
body[data-look="paper"]{ --bg:#e9e1cf; --bg2:#ded4bf; --paper:#f7f1e3; --paper-edge:#d9cdb3; --letter:#26302f; --letter-dim:rgba(38,48,47,.28);
  --ui:#26302f; --ui-muted:#5e6866; --line:rgba(38,48,47,.16); --chip:#f2ead8; --accent:#1f8f6c; --accent-ink:#ffffff; --hl-a:.55; --blend:multiply;
  --h0:#33d39b; --h1:#ff7a63; --h2:#ffcf3f; --h3:#58b4ff; --h4:#b58cff; --h5:#ff86c4; --h6:#a6e04a; --h7:#ff9f45; }
body[data-look="plum"]{ --bg:#1b1026; --bg2:#22142f; --paper:#2b1a3a; --paper-edge:#3d2852; --letter:#f6e9ff; --letter-dim:rgba(246,233,255,.3);
  --ui:#f6e9ff; --ui-muted:#c8b6d6; --line:rgba(246,233,255,.14); --chip:#2b1a3a; --accent:#ffc46b; --accent-ink:#2a1700;
  --h0:#ffc46b; --h1:#ff7fa8; --h2:#8fe3ff; --h3:#b8f27a; --h4:#d39bff; --h5:#ff9d6b; --h6:#7fffd0; --h7:#fff27a; }
body[data-look="moss"]{ --bg:#151d14; --bg2:#1a2419; --paper:#1f2b1e; --paper-edge:#304230; --letter:#eef3e0; --letter-dim:rgba(238,243,224,.3);
  --ui:#eef3e0; --ui-muted:#b7c2a8; --line:rgba(238,243,224,.14); --chip:#1f2b1e; --accent:#c6f06b; --accent-ink:#172000;
  --h0:#c6f06b; --h1:#ffa98a; --h2:#fff09a; --h3:#9fd8ff; --h4:#e3b8ff; --h5:#ffc0d8; --h6:#8ff0c9; --h7:#ffd08a; }

*{ box-sizing:border-box; }
html,body{ margin:0; height:100%; }
body{ background:radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed, var(--bg); color:var(--ui); font:16px/1.4 var(--font);
  -webkit-tap-highlight-color:transparent; overscroll-behavior:none; min-height:100dvh; }
button{ font:inherit; color:inherit; }
.hidden{ display:none !important; }
.vh{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

#top{ display:flex; align-items:center; gap:8px; padding:calc(6px + env(safe-area-inset-top)) 10px 6px; max-width:1100px; margin:0 auto; }
#realmSlot{ flex:0 0 auto; min-width:0; }
.ttl{ flex:1; min-width:0; display:flex; flex-direction:column; line-height:1.15; }
.ttl h1{ margin:0; font:800 19px/1.1 var(--letters); letter-spacing:.01em; }
#sub{ font-size:13px; color:var(--ui-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#clock{ font:600 14px var(--letters); color:var(--ui-muted); font-variant-numeric:tabular-nums; }
.ic{ width:44px; height:44px; border-radius:12px; border:1.5px solid var(--line); background:var(--chip); display:grid; place-items:center; cursor:pointer; flex:0 0 auto; }
.ic svg{ width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.ic:focus-visible,#board:focus-visible,.chip:focus-visible,.opt:focus-visible{ outline:3px solid var(--accent); outline-offset:2px; }

#play{ display:flex; flex-direction:column; align-items:center; gap:10px; padding:4px 4px calc(12px + env(safe-area-inset-bottom)); max-width:1100px; margin:0 auto; }
#boardWrap{ position:relative; width:calc(var(--cell) * var(--n) + 2 * var(--pad)); padding:var(--pad); border-radius:18px; background:var(--paper);
  box-shadow:inset 0 0 0 1.5px var(--paper-edge), 0 10px 30px rgba(0,0,0,.28);
  background-image:radial-gradient(rgba(255,255,255,.035) 1px, transparent 1.2px); background-size:7px 7px; }
#board{ position:relative; display:grid; grid-template-columns:repeat(var(--n), var(--cell)); grid-auto-rows:var(--cell); touch-action:none; user-select:none; -webkit-user-select:none; cursor:pointer; border-radius:10px; z-index:1; }
#ink{ position:absolute; left:var(--pad); top:var(--pad); width:calc(var(--cell) * var(--n)); height:calc(var(--cell) * var(--n)); pointer-events:none; z-index:0; overflow:visible; }
#ink .st{ fill:none; stroke-linecap:round; stroke-width:.74; opacity:var(--hl-a); mix-blend-mode:var(--blend); }
#ink .st.new{ animation:draw .35s ease-out both; }
#ink .pre{ fill:none; stroke-linecap:round; stroke-width:.74; stroke:var(--letter); opacity:.18; }
#ink .pre.miss{ stroke:var(--warn); opacity:.45; animation:miss .4s ease-out both; }
#ink .anchor,#ink .hintc{ fill:none; stroke:var(--accent); stroke-width:.09; }
#ink .hintc{ stroke:var(--h2); stroke-width:.11; animation:pulse 1s ease-in-out infinite; }
#ink .cur{ fill:none; stroke:var(--ui); stroke-width:.06; stroke-dasharray:.12 .1; }
@keyframes draw{ from{ stroke-dasharray:0 40; } to{ stroke-dasharray:40 0; } }
@keyframes miss{ 0%,100%{ transform:translateX(0) } 25%{ transform:translateX(-.12px) } 75%{ transform:translateX(.12px) } }
@keyframes pulse{ 50%{ opacity:.35; } }
.c{ display:grid; place-items:center; font:600 calc(var(--cell) * .64)/1 var(--letters); color:var(--letter); transition:color .3s, opacity .3s, transform .3s; }
.c.f{ font-weight:800; }
#board.big .c{ font-size:max(18px, calc(var(--cell) * .64)); }
#board.done .c{ color:var(--letter-dim); }
#board.done .c.b{ color:var(--letter); font-weight:900; transform:scale(1.18); text-shadow:0 0 12px var(--accent); }
#bonusBanner{ position:absolute; left:50%; bottom:-14px; transform:translate(-50%, 0); z-index:2; background:var(--accent); color:var(--accent-ink); font:800 15px var(--letters);
  padding:7px 14px; border-radius:999px; white-space:nowrap; box-shadow:0 6px 18px rgba(0,0,0,.3); animation:pop .4s ease-out both; }
@keyframes pop{ from{ transform:translate(-50%, 8px) scale(.9); opacity:0; } }

#side{ width:100%; max-width:calc(var(--cell) * var(--n) + 2 * var(--pad)); display:flex; flex-direction:column; gap:8px; }
#hint{ margin:4px 2px 0; font-size:14px; color:var(--ui-muted); text-align:center; min-height:20px; }
#list{ list-style:none; margin:0; padding:0; display:flex; flex-wrap:wrap; gap:6px; justify-content:center; }
#list li{ font:700 15px/1 var(--letters); letter-spacing:.06em; padding:7px 10px 7px 8px; border-radius:999px; background:var(--chip); border:1.5px solid var(--line); display:flex; align-items:center; gap:6px; }
#list li i{ width:10px; height:10px; border-radius:50%; border:1.5px solid var(--ui-muted); flex:0 0 auto; }
#list li.f{ text-decoration:line-through; text-decoration-thickness:2px; color:var(--ui-muted); }
#list li.f i{ border:0; background:var(--hc); box-shadow:0 0 0 2px var(--hc); }
#list li.f i::after{ content:""; display:block; width:4px; height:7px; margin:0 auto; border:solid var(--accent-ink); border-width:0 2px 2px 0; transform:translateY(0) rotate(45deg); }
#actions{ display:flex; align-items:center; gap:8px; justify-content:center; flex-wrap:wrap; }
#count{ font:700 15px var(--letters); color:var(--ui-muted); margin-right:auto; padding-left:4px; font-variant-numeric:tabular-nums; }
#actions .er-btn{ min-height:44px; min-width:88px; }

/* desktop and sideways tablets: board left, words right */
@media (min-width:600px) and (min-aspect-ratio:1001/1000){
  #play{ flex-direction:row; align-items:flex-start; justify-content:center; gap:24px; padding-top:12px; }
  #side{ max-width:320px; padding-top:6px; }
  #list{ justify-content:flex-start; }
  #hint{ text-align:left; }
}

/* the sheet: modes, themes, looks, results */
#scrim{ position:fixed; inset:0; background:rgba(3,10,12,.55); z-index:40; }
#sheet{ position:fixed; z-index:41; left:50%; bottom:0; transform:translateX(-50%); width:min(560px, 100%); max-height:88dvh; overflow:auto;
  background:var(--er-surface, #123438); color:var(--er-ink, #f3ead6); border-radius:20px 20px 0 0; padding:16px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow:0 -10px 40px rgba(0,0,0,.4); animation:up .25s ease-out both; }
body[data-look="paper"] #sheet{ --er-surface:#123438; }
@keyframes up{ from{ transform:translate(-50%, 30px); opacity:0; } }
@media (min-width:700px) and (min-height:600px){ #sheet{ bottom:auto; top:50%; transform:translate(-50%,-50%); border-radius:20px; animation:none; } }
#sheet h2{ margin:0 0 2px; font:800 22px var(--letters); }
#sheet h3{ margin:16px 0 8px; font:700 12px var(--er-kicker-font, monospace); letter-spacing:.12em; text-transform:uppercase; color:var(--er-kicker, #5fe3b3); }
#sheet p{ margin:4px 0; color:var(--er-ink-muted, #b9cbc6); font-size:14px; }
#sheet .x{ position:absolute; right:10px; top:10px; }
.opts{ display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:8px; }
.opt{ text-align:left; min-height:56px; padding:9px 12px; border-radius:14px; border:1.5px solid rgba(243,234,214,.18); background:#184247; color:#f3ead6; cursor:pointer; }
.opt b{ display:block; font:700 16px var(--letters); }
.opt small{ color:#b9cbc6; font-size:12.5px; }
.opt.on{ border-color:#5fe3b3; box-shadow:inset 0 0 0 1.5px #5fe3b3; }
.chips{ display:flex; flex-wrap:wrap; gap:6px; }
.chip{ min-height:44px; padding:0 13px; border-radius:999px; border:1.5px solid rgba(243,234,214,.18); background:#184247; color:#f3ead6; cursor:pointer; font-size:15px; }
.chip.on{ background:#5fe3b3; color:#06201a; border-color:#5fe3b3; font-weight:700; }
.row{ display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:48px; }
.sw{ position:relative; width:52px; height:30px; border-radius:99px; border:0; background:#2c5257; cursor:pointer; flex:0 0 auto; }
.sw::after{ content:""; position:absolute; left:3px; top:3px; width:24px; height:24px; border-radius:50%; background:#f3ead6; transition:left .15s; }
.sw[aria-checked="true"]{ background:#2fae86; }
.sw[aria-checked="true"]::after{ left:25px; }
.looks{ display:grid; grid-template-columns:repeat(auto-fill, minmax(120px, 1fr)); gap:8px; }
.look{ border-radius:14px; border:1.5px solid rgba(243,234,214,.18); background:#184247; color:#f3ead6; padding:8px; cursor:pointer; text-align:left; min-height:44px; }
.look.on{ border-color:#5fe3b3; box-shadow:inset 0 0 0 1.5px #5fe3b3; }
.look .sw8{ display:grid; grid-template-columns:repeat(4,1fr); gap:3px; padding:6px; border-radius:9px; margin-bottom:6px; font:700 13px var(--letters); text-align:center; }
.look .sw8 span{ border-radius:4px; }
.look b{ display:block; font-size:14px; }
.look small{ color:#b9cbc6; }
.stats{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:14px 0; }
.stats div{ background:#184247; border-radius:14px; padding:10px; text-align:center; }
.stats span{ display:block; font-size:12px; color:#b9cbc6; }
.stats b{ font:800 20px var(--letters); }
.btns{ display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.btns .er-btn{ flex:1 1 140px; min-height:48px; }
.how{ margin:0; padding-left:18px; color:#d8e2df; font-size:14px; }
.how li{ margin:3px 0; }
.toast{ position:fixed; left:50%; bottom:calc(24px + env(safe-area-inset-bottom)); transform:translateX(-50%); z-index:60; background:#f3ead6; color:#0c2427; padding:10px 16px; border-radius:12px; font-weight:600; box-shadow:0 8px 24px rgba(0,0,0,.35); }

/* the share card art and cover art (tools/art.mjs) */
body.art #top,body.art #side #actions,body.art #hint{ display:none; }
body.art #play{ flex-direction:row; align-items:center; justify-content:center; gap:44px; height:100dvh; padding:0 40px; max-width:none; }
body.art .brand{ display:block !important; max-width:430px; }
.brand{ display:none; }
.brand .k{ font:700 15px ui-monospace,monospace; letter-spacing:.16em; color:var(--accent); text-transform:uppercase; }
.brand h2{ font:900 76px/0.95 var(--letters); margin:10px 0 14px; }
.brand p{ font-size:22px; color:var(--ui-muted); margin:0 0 18px; }
body.art #list{ justify-content:flex-start; }
body.art #side{ max-width:none; width:auto; }

/* phones: the realm bar and buttons on one row, the title under them */
@media (max-width:520px){
  #top{ flex-wrap:wrap; row-gap:2px; }
  #realmSlot{ margin-right:auto; }
  .ttl{ order:5; flex:1 0 100%; flex-direction:row; align-items:baseline; gap:8px; padding:0 2px; }
  .ttl h1{ font-size:18px; flex:0 0 auto; }
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{ animation:none !important; transition:none !important; }
}
