@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&display=swap');

  :root {
    --espresso: #2f2118; --crema: #f6efe2; --cell: #fffdf8; --block: #2f2118;
    --caramel: #a05a2c; --caramel-soft: #f0d9bd; --foam: #efe0c2;
    --good: #2e7d4f; --bad: #b4372f; --border: #9c8468; --muted: #8a7458;
  }
  * { box-sizing: border-box; }
  body { margin: 0; padding: 22px 16px 48px; color: var(--espresso);
         background: var(--crema);
         background-image: radial-gradient(ellipse at 20% -10%, #fdf8ee 0%, rgba(253,248,238,0) 55%),
                           radial-gradient(ellipse at 90% 110%, #eaddc6 0%, rgba(234,221,198,0) 50%);
         font-family: Georgia, 'Times New Roman', serif; }
  header.brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 0 2px; }
  header.brand svg { width: 46px; height: 46px; flex: 0 0 auto; }
  header.brand .steam { animation: steam 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
  header.brand .steam2 { animation-delay: 1.6s; }
  @keyframes steam { 0% {opacity:.15; transform: translateY(2px) scaleY(.9);}
                     50% {opacity:.7; transform: translateY(-1px) scaleY(1.05);}
                     100% {opacity:.15; transform: translateY(2px) scaleY(.9);} }
  header.brand h1 { margin: 0; font-size: 2rem; letter-spacing: 3px; font-weight: 700;
                    font-family: 'Cinzel', Georgia, serif; text-transform: uppercase; }
  header.brand h1 a { color: inherit; text-decoration: none; }
  .tagline { text-align: center; margin: 0 0 2px; font-style: italic; color: var(--muted); font-size: .95rem; }
  .dateline { text-align: center; margin: 4px 0 0; color: var(--espresso); font-size: .95rem; }
  .sub { text-align: center; margin: 2px 0 6px; font-style: italic; color: var(--muted); font-size: .9rem; }
  #timer { text-align: center; margin: 8px auto 14px; width: fit-content;
           font: 400 .9rem/1 'Helvetica Neue', Arial, sans-serif; letter-spacing: 1.5px;
           color: var(--muted); font-variant-numeric: tabular-nums; }
  #timer.paused { color: #b9a891; font-style: italic; }
  nav.top { text-align: center; margin: 0 0 14px; font-size: .85rem; }
  nav.top a { color: var(--caramel); }
  nav.top .navgroup { position: relative; display: inline-block; }
  nav.top .navgroup > button { font: inherit; color: var(--caramel); background: none;
                               border: 0; padding: 0; cursor: pointer; }
  nav.top .navdrop { display: none; position: absolute; top: 100%; left: 50%; z-index: 50;
                     transform: translateX(-50%); margin-top: 8px; min-width: 170px;
                     padding: 6px; background: var(--cell); border: 1px solid var(--border);
                     border-radius: 10px; box-shadow: 0 6px 20px rgba(47,33,24,.18); }
  nav.top .navgroup.open .navdrop { display: block; }
  nav.top .navdrop a { display: block; padding: 8px 12px; border-radius: 7px;
                       text-align: left; white-space: nowrap; text-decoration: none; }
  nav.top .navdrop a:hover { background: var(--foam); }
  .wrap { display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; align-items: flex-start;
          max-width: 1100px; margin: 0 auto; }
  #grid { border-collapse: collapse; touch-action: manipulation;
          box-shadow: 0 3px 14px rgba(47,33,24,.18); border-radius: 4px; }
  #grid td { width: 46px; height: 46px; border: 1px solid var(--border); position: relative;
             padding: 0; text-align: center; vertical-align: middle; background: var(--cell);
             cursor: pointer; font: 700 1.35rem/1 'Helvetica Neue', Arial, sans-serif; user-select: none;
             transition: background-color .12s ease; }
  #grid td.block { background: var(--block); cursor: default; }
  #grid td .num { position: absolute; top: 1px; left: 3px; font: 400 .58rem/1 Arial, sans-serif; color: var(--muted); }
  /* ---------- micro-motion: the difference between snap and glide ---------- */
  #grid td .letter { display: inline-block; transition: color .15s ease; }
  #grid td .letter.pop { animation: pop .14s cubic-bezier(.2, 1.4, .4, 1); }
  @keyframes pop { from { transform: scale(.55); } to { transform: scale(1); } }
  /* solved: a wave rolls across the grid before the card lands */
  #grid.won .letter { animation: wave .5s cubic-bezier(.3, 1.6, .4, 1) both; }
  @keyframes wave { 0% { transform: none; }
                    30% { transform: translateY(-9px) scale(1.12); }
                    60% { transform: translateY(2px); }
                    100% { transform: none; } }
  #grid td.word { background: var(--foam); }
  #grid td.cur { background: #f5d76e; outline: 2px solid var(--caramel); outline-offset: -2px; }
  #grid td.good { color: var(--good); }
  #grid td.bad { color: var(--bad); }
  /* the red alone is invisible to some eyes — a slash says wrong on its own */
  #grid td.bad::after { content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(to top right, transparent 47%, var(--bad) 47%,
                                var(--bad) 53%, transparent 53%);
    opacity: .35; animation: slashin .18s ease; }
  @keyframes slashin { from { opacity: 0; } to { opacity: .35; } }
  .toolbar { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
  button { font: 600 .85rem/1 'Helvetica Neue', Arial, sans-serif; padding: 9px 14px;
           border: 1.5px solid var(--espresso); border-radius: 999px; background: var(--cell);
           color: var(--espresso); cursor: pointer;
           transition: background-color .15s ease, transform .05s ease; }
  button:hover { background: var(--caramel-soft); }
  button:active { transform: translateY(1px); }
  /* The clue block has to be able to shrink, or it keeps its two 250px columns
     and drops below the grid on any window under about 1000px — which is most
     laptops. It now takes whatever is left beside the grid and folds to one
     column when that is tight. */
  .clues { display: flex; gap: 26px; flex-wrap: wrap;
           flex: 1 1 300px; min-width: 300px; max-width: 560px; }
  .cluecol { min-width: 200px; flex: 1 1 200px; }
  /* the toolbar is wider than the grid and was pushing the clues a further
     150px right; let it wrap under the grid instead */
  .left { flex: 0 0 auto; max-width: 420px; }
  .cluecol h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 2px;
                border-bottom: 2px solid var(--caramel); padding-bottom: 4px; margin: 0 0 8px; }
  ol.cluelist { list-style: none; margin: 0; padding: 0; font-size: .93rem; }
  ol.cluelist li { padding: 5px 6px; border-radius: 5px; cursor: pointer; line-height: 1.35;
                   transition: background-color .12s ease, box-shadow .12s ease; }
  ol.cluelist li b { font-family: Arial, sans-serif; margin-right: 6px; color: var(--caramel); }
  ol.cluelist li.active { background: var(--foam); box-shadow: inset 3px 0 0 var(--caramel); }
  ol.cluelist li.done { color: #ab9c86; }
  /* answer length, shown after every clue */
  .len { color: var(--muted); font-weight: 400; font-size: .8em;
         font-family: Arial, sans-serif; white-space: nowrap; }
  ol.cluelist li.done .len { color: inherit; }
  #msg { text-align: center; margin-top: 16px; font-size: 1.05rem; min-height: 1.4em; font-weight: 700; }
  #msg.win { color: var(--good); }
  .foot { text-align: center; margin-top: 26px; color: var(--muted); font-size: .8rem; }

  /* ---------- desktop clue bar: the clue you are on, next to the grid ---------- */
  #deskClue { display: flex; align-items: stretch; gap: 6px; max-width: 420px;
              margin: 0 auto 10px; }
  #deskClue button.nav { flex: 0 0 38px; font-size: 1.2rem; border-radius: 9px; padding: 0;
                         background: var(--foam); border-color: var(--border); }
  #dClue { flex: 1; background: var(--foam); border: 1px solid var(--border);
           border-radius: 9px; padding: 7px 10px; font-size: .95rem; line-height: 1.3;
           display: flex; align-items: center; min-height: 42px; cursor: pointer; }
  #dClue b { font-family: Arial, sans-serif; color: var(--caramel); margin-right: 8px; }

  /* ---------- mobile dock: clue bar + in-page keyboard ---------- */
  #mobileDock { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
                background: var(--crema); border-top: 1px solid var(--border);
                padding: 6px 6px calc(8px + env(safe-area-inset-bottom, 0px));
                box-shadow: 0 -3px 14px rgba(47,33,24,.12); }
  #cluebar { display: flex; align-items: stretch; gap: 6px; }
  #cluebar button.nav { flex: 0 0 42px; font-size: 1.35rem; border-radius: 9px; padding: 0;
                        background: var(--foam); border-color: var(--border); }
  #curClue { flex: 1; background: var(--foam); border: 1px solid var(--border);
             border-radius: 9px; padding: 7px 10px; font-size: .92rem; line-height: 1.25;
             display: flex; align-items: center; min-height: 46px; overflow: hidden; }
  #curClue.clue-swap, #dClue.clue-swap { animation: clueslide .18s ease; }
  @keyframes clueslide { from { opacity: 0; transform: translateY(4px); }
                         to { opacity: 1; transform: none; } }
  #curClue b { font-family: Arial, sans-serif; color: var(--caramel); margin-right: 8px; }
  .kbd-row { display: flex; gap: 5px; justify-content: center; margin-top: 6px; }
  .kbd-key { flex: 1 1 0; max-width: 42px; height: 46px; border: 1px solid #c9b8a0;
             border-radius: 7px; background: #fffdf8; color: var(--espresso);
             font: 600 1.12rem/1 'Helvetica Neue', Arial, sans-serif;
             display: flex; align-items: center; justify-content: center;
             box-shadow: 0 1.5px 0 #c9b8a0; user-select: none; touch-action: manipulation;
             transition: background-color .1s ease, transform .06s ease, box-shadow .06s ease; }
  /* pointerdown preventDefault suppresses :active on touch — the .pressed class
     is what actually lights a key under a finger */
  .kbd-key:active, .kbd-key.pressed { background: var(--foam); transform: translateY(1px); box-shadow: none; }
  .kbd-key.wide { max-width: 64px; flex: 1.4 1 0; font-size: 1.25rem; }
  .kbd-key.act { max-width: 64px; flex: 1.4 1 0; background: var(--caramel-soft);
                 color: var(--caramel); font-size: 1.25rem; }
  #kbd { position: fixed; top: 0; left: 0; width: 2px; height: 2px; opacity: .01;
         border: 0; padding: 0; background: transparent; }
  @media (max-width: 700px) {
    body { padding: 6px 4px 240px; }
    header.brand { gap: 8px; }
    header.brand svg { width: 26px; height: 26px; }
    header.brand h1 { font-size: 1.3rem; }
    .tagline, .dateline, .sub, nav.top { display: none; }
    #timer { margin: 6px auto 8px; font-size: .85rem; }
    .wrap { gap: 8px; }
    .clues { display: none; }
    #deskClue { display: none; }
    #mobileDock { display: block; }
    #grid { margin: 0 auto; box-shadow: none; }
    #grid td { width: min(calc((100vw - 12px) / 9), 46px);
               height: min(calc((100vw - 12px) / 9), 46px);
               font-size: clamp(1rem, 4.6vw, 1.3rem); }
    #grid td .num { font-size: .5rem; top: 0; left: 2px; }
    .toolbar { margin-top: 8px; gap: 6px; }
    .toolbar button { padding: 7px 10px; font-size: .78rem; }
    #msg { margin-top: 8px; font-size: .95rem; }
    html:not(.doc) .foot { display: none; }      /* prose pages need theirs */
  }

  /* ---------- mobile lockdown: no zoom, single screen, top bar ---------- */
  html { touch-action: manipulation; -webkit-text-size-adjust: 100%;
         -webkit-tap-highlight-color: transparent; }
  #kbd { font-size: 16px; }
  #mtop { display: none; }
  #menuSheet { display: none; }
  @media (max-width: 700px) {
    /* html.doc marks a page that is a document, not the app. The lockdown below
       is right for a puzzle — one screen, no scroll, no rubber-banding — and
       wrong for prose: it strands everything past the first screen, including
       the only links out. In the installed PWA there is no browser chrome to
       escape with, so that is a dead end with no way back at all. */
    html:not(.doc), html:not(.doc) body {
      height: 100dvh; overflow: hidden; overscroll-behavior: none; }
    html:not(.doc) body { padding: 0 4px; }
    header.brand, .tagline, .dateline, .sub, nav.top { display: none; }
    /* .foot is the app's own footer line on a puzzle page — but on a prose page
       it is the row of links to everywhere else. */
    html:not(.doc) .foot { display: none; }
    #mtop { display: flex; align-items: center; gap: 8px; padding: 8px 4px 6px; position: relative; }
    #mtop .mbrand { font: 700 clamp(1.1rem, 5.5vw, 1.35rem)/1 'Cinzel', Georgia, serif;
                    text-transform: uppercase; letter-spacing: 3px;
                    position: absolute; left: 50%; transform: translateX(-50%); }
    #mtSlotTimer { flex: 0 0 auto; min-width: 44px; }
    #mtop #timer { margin: 0; font-size: .82rem; flex: 0 0 auto; }
    #mtSlotMsg { flex: 1; min-width: 0; }
    #mtSlotMsg #msg { margin: 0; font-size: .8rem; text-align: left;
                      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #menuBtn { margin-left: auto; flex: 0 0 40px; width: 40px; height: 36px; padding: 0;
               font-size: 1.25rem; line-height: 1; border-radius: 9px; }
    #menuSheet.open { display: block; position: fixed; top: 54px; right: 8px; z-index: 80;
                      background: #fffdf8; border: 1px solid var(--border); border-radius: 12px;
                      padding: 10px; box-shadow: 0 8px 24px rgba(47,33,24,.3); min-width: 170px;
                      transform-origin: top right; animation: sheetin .16s ease; }
    #menuSheet .menu-nav { display: flex; flex-direction: column; gap: 8px;
                           margin: 0 0 10px; padding: 0 0 10px;
                           border-bottom: 1px solid var(--border); }
    #menuSheet .menu-nav a { display: block; width: 100%; padding: 10px 12px;
                             border: 1.5px solid var(--espresso); border-radius: 999px;
                             background: var(--cell); color: var(--espresso);
                             font: 600 .88rem/1 'Helvetica Neue', Arial, sans-serif;
                             text-align: center; text-decoration: none; }
    #menuSheet .menu-nav .menu-group > button { display: block; width: 100%;
                             padding: 10px 12px; border: 1.5px solid var(--espresso);
                             border-radius: 999px; background: var(--cell);
                             color: var(--espresso); text-align: center; cursor: pointer;
                             font: 600 .88rem/1 'Helvetica Neue', Arial, sans-serif; }
    #menuSheet .menu-nav .menu-sub { display: none; flex-direction: column; gap: 8px;
                                     margin-top: 8px; }
    #menuSheet .menu-nav .menu-group.open .menu-sub { display: flex; }
    /* dashed, so a child reads as one level in rather than another peer */
    #menuSheet .menu-nav .menu-sub a { background: var(--crema); border-style: dashed; }
    #menuSheet .toolbar { flex-direction: column; margin: 0; gap: 8px; }
    #menuSheet .toolbar button { width: 100%; padding: 10px 12px; font-size: .88rem; }
    .wrap { gap: 0; }
    #grid { margin: 2px auto 0; }
  }

  /* the sentence the page ships with, kept after the app takes over */
  .seo-note { max-width: 560px; margin: 26px auto 0; padding: 0 16px;
              font-size: .82rem; line-height: 1.6; color: var(--espresso);
              opacity: .6; text-align: center; }
  @media (max-width: 700px) { .seo-note { display: none; } }

  .seo-about { max-width: 560px; margin: 34px auto 60px; padding: 26px 16px 0;
               border-top: 1px solid var(--border); }
  .seo-about h2 { font-family: 'Cinzel', Georgia, serif; font-size: 1rem;
                  letter-spacing: 2px; text-transform: uppercase; margin: 0 0 12px; }
  .seo-about p { font-size: .92rem; line-height: 1.7; color: var(--espresso);
                 opacity: .85; margin: 0 0 12px; }
  @media (max-width: 700px) { .seo-about { display: none; } }

  /* ---------- prose pages ---------- */
  /* A way back that is reachable without scrolling — the footer links sit past
     the end of a long read, and in the PWA there is no back button above them. */
  .docnav { display: inline-block; margin: 0 0 16px; color: var(--caramel);
            text-decoration: none;
            font: 600 .85rem/1 'Helvetica Neue', Arial, sans-serif; }
  .docnav:hover { text-decoration: underline; }

  /* ---------- what's-new modal ---------- */
  #newsModal { position: fixed; inset: 0; z-index: 110; display: flex;
               align-items: center; justify-content: center; padding: 16px;
               background: rgba(47,33,24,.45); animation: newsfade .25s ease; }
  @keyframes newsfade { from { opacity: 0; } to { opacity: 1; } }
  .news-card { background: var(--cell); border: 1px solid var(--border); border-radius: 14px;
               padding: 20px 20px 16px; width: min(92vw, 380px); position: relative;
               box-shadow: 0 12px 40px rgba(47,33,24,.35);
               font-family: Georgia, 'Times New Roman', serif; font-size: .92rem;
               animation: cardin .35s cubic-bezier(.2, 1.3, .4, 1); }
  @keyframes cardin { from { opacity: 0; transform: scale(.9) translateY(8px); }
                      to { opacity: 1; transform: none; } }
  @keyframes sheetin { from { opacity: 0; transform: scale(.95) translateY(-4px); }
                       to { opacity: 1; transform: none; } }
  .news-card b { display: block; color: var(--caramel); margin-bottom: 10px;
                 font: 700 .7rem/1 'Helvetica Neue', Arial, sans-serif;
                 letter-spacing: .12em; text-transform: uppercase; }
  .news-card ul { margin: 0; padding-left: 18px; }
  .news-card li { margin: 7px 0; line-height: 1.5; }
  .news-card .news-close { position: absolute; top: 5px; right: 7px; background: none;
                           border: 0; color: var(--muted); font: 400 1.3rem/1 Georgia, serif;
                           cursor: pointer; padding: 4px 7px; }
  .news-card .news-close:hover { color: var(--espresso); }
  .news-card .news-go { width: 100%; margin-top: 16px; padding: 11px; border: none;
                        border-radius: 8px; background: var(--espresso); color: #fff;
                        font: 600 .95rem/1 'Helvetica Neue', Arial, sans-serif;
                        cursor: pointer; }
  .news-card .news-go:hover { background: var(--caramel); }

  /* ---------- account modal ---------- */
  #authModal { position: fixed; inset: 0; z-index: 100; display: flex;
               align-items: center; justify-content: center;
               background: rgba(47,33,24,.45); }
  #authModal[hidden] { display: none; }
  .auth-card { background: #fffdf8; border: 1px solid var(--border); border-radius: 14px;
               padding: 20px 18px 16px; width: min(92vw, 340px); position: relative;
               box-shadow: 0 12px 40px rgba(47,33,24,.35);
               font-family: 'Helvetica Neue', Arial, sans-serif;
               animation: cardin .35s cubic-bezier(.2, 1.3, .4, 1); }
  .auth-card h3 { margin: 0 0 12px; font-family: Georgia, serif; font-size: 1.15rem; }
  .auth-card input { width: 100%; padding: 10px 11px; margin-bottom: 8px;
                     border: 1px solid var(--border); border-radius: 8px; font-size: 16px;
                     background: #fff; }
  .auth-card .authGo { width: 100%; padding: 11px; border-radius: 8px;
                       background: var(--espresso); color: #fff; border: none;
                       font-weight: 600; font-size: .95rem; cursor: pointer; }
  .auth-card .authGo:hover { background: var(--caramel); }
  .auth-links { margin-top: 10px; font-size: .82rem; display: flex;
                justify-content: space-between; gap: 8px; flex-wrap: wrap; }
  .auth-links a { color: var(--caramel); cursor: pointer; text-decoration: underline; }
  #authMsg { margin-top: 10px; font-size: .82rem; min-height: 1.2em; line-height: 1.35; }
  #authMsg.err { color: var(--bad); }
  #authMsg.ok { color: var(--good); }
  .auth-close { position: absolute; top: 6px; right: 8px; border: none; background: none;
                font-size: 1.35rem; cursor: pointer; color: var(--muted); padding: 4px 8px;
                box-shadow: none; }

/* ---------- solved lock ---------- */
#gridLockWrap { position: relative; width: fit-content; margin: 0 auto; }
#grid.locked { pointer-events: none; }
#grid.dimmed { filter: grayscale(.85) opacity(.45); transition: filter .8s ease; }
#solvedOverlay { position: absolute; inset: 0; display: flex; align-items: center;
                 justify-content: center; z-index: 40; animation: ovfade .5s ease; }
@keyframes ovfade { from { opacity: 0; } to { opacity: 1; } }
.solved-card { background: rgba(255,253,248,.95); border: 1px solid #d8c8ae; border-radius: 14px;
               padding: 18px 22px; text-align: center; max-width: 86%;
               font-family: Georgia, 'Times New Roman', serif;
               box-shadow: 0 6px 24px rgba(47,33,24,.22);
               animation: cardin .35s cubic-bezier(.2, 1.3, .4, 1); }
.solved-card .t1 { font-size: 1.15rem; font-weight: 700; color: var(--espresso); margin-bottom: 8px; }
/* the streak: the count stamped in a coffee ring, best right under it */
.solved-card .streak { display: flex; flex-direction: column; align-items: center; gap: 2px;
                       margin: 2px 0 10px; color: var(--caramel); font-size: .95rem; }
.solved-card .streak[hidden] { display: none; }
.solved-card .streak .ringbox { position: relative; width: 56px; height: 56px;
                                display: flex; align-items: center; justify-content: center; }
.solved-card .streak .ringbox svg { position: absolute; inset: 0; }
.solved-card .streak .ringbox b { font-size: 1.45rem; font-weight: 700; color: var(--espresso); }
.solved-card .streak .best { color: var(--muted); font-size: .85rem; }
.solved-card .streak.revealed { color: var(--muted); font-style: italic; }
.solved-card .sharebtn { margin: 2px 0 10px; padding: 9px 20px; border: none;
                         border-radius: 999px; background: var(--espresso); color: #fff;
                         font: 600 .88rem/1 'Helvetica Neue', Arial, sans-serif; cursor: pointer; }
.solved-card .sharebtn:hover { background: var(--caramel); }
.solved-card .cardlinks { display: flex; gap: 16px; justify-content: center; }
.solved-card .community { margin-top: 12px; }
.solved-card .communitylink { display: inline-flex; color: var(--caramel); }
.solved-card .communitylink:hover { color: var(--espresso); }
.solved-card .viewlink { display: inline-block; color: var(--caramel); font-size: .9rem;
                         cursor: pointer; text-decoration: underline; }
#mobileDock.dock-hidden { display: none !important; }
#deskClue.dock-hidden { display: none; }

/* ---------- calmer for those who ask for it ---------- */
@media (prefers-reduced-motion: reduce) {
  header.brand .steam, header.brand .steam2 { animation: none; }
  #newsModal, #solvedOverlay, .news-card, .solved-card, .auth-card,
  #menuSheet.open, #curClue.clue-swap, #dClue.clue-swap,
  #grid td .letter.pop, #grid.won .letter, #grid td.bad::after { animation: none; }
  #grid td, #grid td .letter, button, .kbd-key, ol.cluelist li { transition: none; }
}
