/* Daily Hub — calm, paper-like. Tokens first; dark via prefers-color-scheme. */
:root {
  --bg: #f4efe6;
  --paper: #fbf8f2;
  --paper-2: #ece6da;
  --ink: #1f1b16;
  --ink-2: #4e473f;
  --muted: #6a6256;
  --line: rgba(31,27,22,.14);
  --line-strong: rgba(31,27,22,.32);
  --accent: #a84a24;       /* terracotta */
  --accent-ink: #fff;
  --ochre: #c9962b;
  --moss: #5f8f5a;
  --slate: #5a7a94;
  --plum: #8a5a8f;
  --grey: #a7a097;
  --focus: #b5542d;
  --shadow: 0 1px 0 rgba(31,27,22,.04), 0 10px 24px -14px rgba(31,27,22,.25);
  --radius: 14px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  /* puzzle colours */
  --w-correct: #4f7f4a; --w-present: #9a6f0f; --w-absent: #7a7268;
  --c1: #e9d58f; --c2: #b7d3a3; --c3: #a9c6e2; --c4: #cfb3d8;
  --q0: #e9d58f; --q1: #b7d3a3; --q2: #a9c6e2; --q3: #cfb3d8; --q4: #f0b9a4; --q5: #bfe0dc; --q6: #ddd0b4; --q7: #d9c3ea;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --paper: #201d16;
    --paper-2: #2a261e;
    --ink: #ece6da;
    --ink-2: #c9c1b3;
    --muted: #978f82;
    --line: rgba(236,230,218,.14);
    --line-strong: rgba(236,230,218,.34);
    --accent: #d98457;
    --accent-ink: #17150f;
    --ochre: #d8a93e;
    --moss: #7fae78;
    --slate: #7f9fb8;
    --plum: #ad84b2;
    --grey: #6b655c;
    --shadow: 0 10px 24px -14px rgba(0,0,0,.6);
    --w-correct: #4f7f4a; --w-present: #9a6f0f; --w-absent: #4a453d;
    --c1: #6e6226; --c2: #3f6a36; --c3: #3f6688; --c4: #6f4f78;
    --q0: #6e6226; --q1: #3f6a36; --q2: #3f6688; --q3: #6f4f78; --q4: #8f5a44; --q5: #3f7570; --q6: #6b5f3c; --q7: #5d4a78;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(201,150,43,.08), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(181,84,45,.07), transparent 60%);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 600; line-height: 1.12; letter-spacing: -.01em; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 8px; max-width: 760px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 1.3rem; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink-2); text-decoration: none; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.lang-wrap select { font: inherit; font-weight: 600; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; min-height: 40px; }

/* Main */
.app { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; }
.app:focus { outline: none; }
.screen { animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { padding: 10px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.kicker { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.hero h1 { font-size: clamp(2rem, 7vw, 2.9rem); margin-top: 6px; font-weight: 700; }
.hero p { color: var(--ink-2); margin-top: 8px; max-width: 52ch; }
.hero .meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-size: .95rem; }
.hero .meta b { color: var(--ink); font-weight: 700; }

.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 600px) { .cards { grid-template-columns: 1fr 1fr; } .cards .card:first-child { grid-column: 1 / -1; } }
.card {
  display: flex; gap: 14px; align-items: center; text-align: left; width: 100%;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; box-shadow: var(--shadow); text-decoration: none; color: inherit;
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { border-color: var(--line-strong); }
.card:active { transform: scale(.99); }
.card .ico { flex: 0 0 52px; width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 28%, var(--paper)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); }
.card .ico svg { width: 26px; height: 26px; }
.card .body { flex: 1; min-width: 0; }
.card h2 { font-size: 1.25rem; }
.card p { color: var(--muted); font-size: .95rem; margin-top: 2px; }
.card .state { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: .85rem; font-weight: 700; color: var(--ink-2); padding: 3px 9px; border-radius: 999px; background: var(--paper-2); }
.card .state.done { background: color-mix(in srgb, var(--moss) 22%, var(--paper)); color: var(--ink); }
.card .state.lost { background: color-mix(in srgb, var(--accent) 18%, var(--paper)); }
.card .arrow { color: var(--muted); flex: 0 0 auto; }

.note { margin-top: 18px; color: var(--muted); font-size: .92rem; text-align: center; }

/* Game screens */
.g-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.g-head .back { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; }
.g-head h1 { font-size: 1.5rem; flex: 1; }
.g-head .num { color: var(--muted); font-family: var(--sans); font-size: .95rem; font-weight: 600; white-space: nowrap; }
.g-sub { color: var(--muted); font-size: .95rem; margin-bottom: 14px; }
.howto { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.howto summary { cursor: pointer; font-weight: 700; padding: 10px 14px; color: var(--ink-2); list-style: none; display: flex; justify-content: space-between; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: "+"; color: var(--muted); }
.howto[open] summary::after { content: "–"; }
.howto .inner { padding: 0 14px 12px; color: var(--ink-2); font-size: .95rem; }
.howto ul { margin: 0; padding-left: 18px; }
.howto li + li { margin-top: 4px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 12px; }
.panel h2 { font-size: 1.15rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row.center { justify-content: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 16px; font-weight: 700; font-size: 1rem;
  cursor: pointer; background: var(--paper); color: var(--ink); text-decoration: none; min-height: 44px;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { border-color: var(--line); background: transparent; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }

.status { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: .95rem; margin: 10px 0; flex-wrap: wrap; }
.status b { color: var(--ink); }
.msg { min-height: 1.4em; text-align: center; font-weight: 700; color: var(--ink-2); margin: 8px 0; }

/* Result panel */
.result { text-align: center; padding: 20px 16px; }
.result .big { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; }
.result .sub { color: var(--muted); margin-top: 4px; }
.result .answer { margin-top: 10px; font-family: var(--serif); font-size: 1.4rem; letter-spacing: .08em; }
.result .emoji { white-space: pre; font-size: 1.05rem; line-height: 1.3; margin-top: 12px; }
.result .next { margin-top: 12px; color: var(--muted); font-size: .9rem; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Word ---------- */
.w-board { display: grid; grid-template-rows: repeat(6, 1fr); gap: 6px; max-width: 330px; margin: 8px auto 12px; }
.w-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.w-tile {
  aspect-ratio: 1; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: clamp(1.4rem, 7vw, 2rem);
  border: 2px solid var(--line); border-radius: 8px; background: var(--paper); text-transform: uppercase; color: var(--ink);
}
.w-tile.filled { border-color: var(--line-strong); }
.w-tile.correct { background: var(--w-correct); border-color: var(--w-correct); color: #fff; }
.w-tile.present { background: var(--w-present); border-color: var(--w-present); color: #fff; }
.w-tile.absent { background: var(--w-absent); border-color: var(--w-absent); color: #fff; }
.w-row.reveal .w-tile { animation: flip .5s ease both; }
.w-row.reveal .w-tile:nth-child(2) { animation-delay: .1s; } .w-row.reveal .w-tile:nth-child(3) { animation-delay: .2s; }
.w-row.reveal .w-tile:nth-child(4) { animation-delay: .3s; } .w-row.reveal .w-tile:nth-child(5) { animation-delay: .4s; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.w-row.shake { animation: shake .4s ease; }
@keyframes shake { 0%,100% { transform: none; } 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }

.kb { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; user-select: none; }
.kb-row { display: flex; justify-content: center; gap: 4px; }
.kb .key {
  flex: 1 1 0; max-width: 44px; min-width: 0; height: 50px; border: 0; border-radius: 6px; background: var(--paper-2); color: var(--ink);
  font-weight: 700; font-size: .95rem; cursor: pointer; text-transform: uppercase; display: grid; place-items: center; padding: 0;
}
.kb .key.wide { flex: 1.6 1 0; max-width: 72px; font-size: .75rem; }
.kb .key.correct { background: var(--w-correct); color: #fff; }
.kb .key.present { background: var(--w-present); color: #fff; }
.kb .key.absent { background: var(--w-absent); color: #fff; }
.kb .key svg { width: 20px; height: 20px; }

/* ---------- Connections ---------- */
.cn-groups { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.cn-group { border-radius: 10px; padding: 12px; text-align: center; color: #1f1b16; background: var(--gc); }
.cn-group b { display: block; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; }
.cn-group span { font-size: .95rem; }
@media (prefers-color-scheme: dark) { .cn-group { color: var(--ink); } }
.cn-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cn-tile {
  min-height: 68px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); cursor: pointer;
  font-weight: 700; text-transform: uppercase; font-size: clamp(.68rem, 2.9vw, .95rem); line-height: 1.1; padding: 6px 4px; word-break: break-word; hyphens: auto;
  transition: transform .1s ease;
}
.cn-tile.sel { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.cn-tile:active { transform: scale(.96); }
.cn-tile.bounce { animation: bounce .35s ease; }
@keyframes bounce { 50% { transform: translateY(-6px); } }
.cn-mist { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 12px 0 4px; color: var(--muted); font-size: .95rem; }
.cn-mist .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink-2); display: inline-block; }
.cn-mist .dot.off { background: var(--line); }

/* ---------- Strands ---------- */
.st-theme { text-align: center; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 10px; margin-bottom: 12px; background: var(--paper); }
.st-theme .kicker { margin-bottom: 2px; }
.st-theme h2 { font-size: 1.35rem; }
.st-wrap { position: relative; max-width: 340px; margin: 0 auto; touch-action: none; }
.st-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.st-cell {
  aspect-ratio: 1; border: 0; border-radius: 50%; background: transparent; font-family: var(--serif); font-weight: 700; font-size: clamp(1.1rem, 5.5vw, 1.5rem);
  color: var(--ink); cursor: pointer; display: grid; place-items: center; text-transform: uppercase; position: relative; z-index: 1; padding: 0;
}
.st-cell.sel { background: var(--paper-2); box-shadow: inset 0 0 0 2px var(--line-strong); }
.st-cell.found { background: var(--slate); color: #fff; }
.st-cell.span { background: var(--ochre); color: #1f1b16; }
.st-cell.hint { box-shadow: inset 0 0 0 2px var(--accent); }
.st-current { text-align: center; min-height: 2rem; font-family: var(--serif); font-size: 1.4rem; letter-spacing: .1em; text-transform: uppercase; margin: 8px 0 4px; }
.st-lines { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.st-lines path { fill: none; stroke: var(--line-strong); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Queens ---------- */
.qn-wrap { max-width: 400px; margin: 0 auto; }
.qn-grid { display: grid; gap: 0; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--ink); }
.qn-cell {
  aspect-ratio: 1; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center; font-size: clamp(1rem, 5vw, 1.5rem); position: relative;
  background: var(--qc); color: #1f1b16; outline-offset: -3px;
}
@media (prefers-color-scheme: dark) { .qn-cell { color: var(--ink); } }
.qn-cell.bt { box-shadow: inset 0 2px 0 var(--ink); }
.qn-cell.bl { box-shadow: inset 2px 0 0 var(--ink); }
.qn-cell.bt.bl { box-shadow: inset 2px 0 0 var(--ink), inset 0 2px 0 var(--ink); }
.qn-cell .x { opacity: .55; font-size: .8em; font-weight: 700; }
.qn-cell.bad::after { content: ""; position: absolute; inset: 3px; border: 2px solid #c0392b; border-radius: 4px; pointer-events: none; }
.qn-cell.queen { font-size: clamp(1.2rem, 6vw, 1.8rem); }

/* ---------- Mini crossword ---------- */
.mn-wrap { display: grid; gap: 14px; }
@media (min-width: 640px) { .mn-wrap { grid-template-columns: 300px 1fr; align-items: start; } }
.mn-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; background: var(--ink); border: 2px solid var(--ink); border-radius: 6px; max-width: 300px; margin: 0 auto; }
.mn-cell { aspect-ratio: 1; background: var(--paper); position: relative; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: clamp(1.2rem, 6vw, 1.7rem); text-transform: uppercase; border: 0; padding: 0; cursor: pointer; color: var(--ink); }
.mn-cell.black { background: var(--ink); cursor: default; }
.mn-cell .n { position: absolute; top: 2px; left: 4px; font-family: var(--sans); font-size: .6rem; font-weight: 700; color: var(--muted); }
.mn-cell.word { background: color-mix(in srgb, var(--ochre) 22%, var(--paper)); }
.mn-cell.cur { background: color-mix(in srgb, var(--ochre) 55%, var(--paper)); }
.mn-cell.wrong { color: var(--accent); text-decoration: line-through; }
.mn-cell.revealed { color: var(--slate); }
.mn-cluebar { display: flex; align-items: center; gap: 8px; background: var(--paper-2); border-radius: 10px; padding: 10px 12px; margin-top: 10px; min-height: 48px; }
.mn-cluebar b { font-family: var(--sans); color: var(--muted); font-size: .85rem; white-space: nowrap; }
.mn-cluebar span { flex: 1; font-weight: 600; }
.mn-cluebar button { border: 0; background: transparent; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }
.mn-clues { display: grid; gap: 12px; }
@media (min-width: 420px) and (max-width: 639px) { .mn-clues { grid-template-columns: 1fr 1fr; } }
.mn-clues h3 { font-family: var(--sans); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.mn-clues ol { list-style: none; margin: 0; padding: 0; }
.mn-clues li { padding: 6px 8px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; font-size: .95rem; }
.mn-clues li b { color: var(--muted); font-weight: 700; min-width: 1.4em; }
.mn-clues li.cur { background: color-mix(in srgb, var(--ochre) 28%, var(--paper)); }
.mn-clues li.done { color: var(--muted); text-decoration: line-through; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; text-align: center; }
.stat-grid div { background: var(--paper-2); border-radius: 10px; padding: 10px 4px; }
.stat-grid b { display: block; font-family: var(--serif); font-size: 1.5rem; }
.stat-grid span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dist { margin-top: 12px; display: grid; gap: 4px; }
.dist div { display: grid; grid-template-columns: 1.2em 1fr; gap: 8px; align-items: center; font-size: .9rem; }
.dist .bar { background: var(--ink-2); color: var(--bg); border-radius: 4px; padding: 2px 6px; min-width: 1.6em; text-align: right; font-weight: 700; }
.dist .bar.hit { background: var(--moss); color: #fff; }

/* Footer */
.foot { max-width: 760px; width: 100%; margin: 0 auto; padding: 22px 16px 40px; color: var(--muted); font-size: .95rem; text-align: center; border-top: 1px solid var(--line); }
.foot-line + .foot-line, .foot-line + .cta, .cta + .foot-line { margin-top: 12px; }
.foot-line a { color: var(--ink); font-weight: 700; }
.foot-line.small { font-size: .88rem; }
.cta { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; }
.cta-kicker { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.cta-text { font-family: var(--serif); font-size: 1.2rem; color: var(--ink); margin-top: 6px; }
.store-badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 10px; background: var(--ink); color: var(--bg); border-radius: 10px;
  padding: 8px 14px 8px 12px; text-decoration: none; min-width: 150px; text-align: left; border: 1px solid transparent;
}
.badge svg { width: 26px; height: 26px; flex: 0 0 26px; }
.badge small { display: block; font-size: .65rem; opacity: .8; line-height: 1; }
.badge b { display: block; font-size: 1.05rem; line-height: 1.15; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .screen, .w-row.reveal .w-tile, .w-row.shake, .cn-tile.bounce { animation: none; }
  .btn, .card, .cn-tile, .toast { transition: none; }
}
@media (max-width: 380px) {
  body { font-size: 16px; }
  .kb .key { height: 46px; font-size: .85rem; }
  .cn-tile { min-height: 60px; }
}
