/* Unscramblr — one family, one accent, tiles as the signature. */
:root {
  --paper: #f3f5f9;
  --surface: #ffffff;
  --ink: #181b24;
  --ink-2: #5a6070;
  --ink-3: #8b91a0;
  --line: #dde1ea;
  --tile: #ffffff;
  --tile-edge: #e6d9b8;
  --tile-shadow: #d9cfae;
  --found: #14a37a;
  --found-ink: #0b6b4f;
  --found-soft: #e3f6ee;
  --hint: #f4b63a;
  --hint-soft: #fff4d6;
  --focus: #2f6fed;
  --radius: 14px;
  --radius-s: 8px;
  --font: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --maxw: 680px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #13151c; --surface: #1b1e27; --ink: #eef0f5; --ink-2: #aab0bf; --ink-3: #7c8292; --line: #2b2f3b;
    --tile: #262a36; --tile-edge: #3a3f4f; --tile-shadow: #0d0f14; --found-soft: #10332a; --found-ink: #5fd7b0; --hint-soft: #3a2f10; --focus: #7ea3ff;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.5;
  font-optical-sizing: auto;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.layout { display: grid; grid-template-columns: minmax(0, var(--maxw)); justify-content: center; gap: 32px; }
@media (min-width: 1120px) { .layout { grid-template-columns: minmax(0, var(--maxw)) 300px; } }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand .mark { display: inline-grid; place-items: center; width: 34px; height: 34px; background: var(--tile); border: 1.5px solid var(--tile-edge); border-radius: 8px; box-shadow: 0 2px 0 var(--tile-shadow); font-weight: 800; font-size: 1.05rem; transform: rotate(-6deg); }
.topnav { display: flex; align-items: center; gap: 10px; }
.topnav details { position: relative; }
.topnav summary { list-style: none; cursor: pointer; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .95rem; white-space: nowrap; }
.topnav summary::-webkit-details-marker { display: none; }
.topnav .menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 230px; box-shadow: 0 12px 30px rgba(10, 14, 30, .12); z-index: 20; }
.topnav .menu a { display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; font-size: .95rem; }
.topnav .menu a:hover, .topnav .menu a[aria-current] { background: var(--paper); }
.langsel { padding: 8px 32px 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238b91a0' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat right 12px center; appearance: none; -webkit-appearance: none; font-weight: 600; font-size: .95rem; }

/* Hero + tool */
.hero { padding: 24px 0 8px; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 8px; font-weight: 800; }
.lead { color: var(--ink-2); margin: 0 0 18px; font-size: 1.05rem; }

.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.inputrow { display: flex; gap: 10px; align-items: stretch; }
.letters {
  flex: 1; min-width: 0; font-size: clamp(1.4rem, 5vw, 2rem); letter-spacing: .12em; text-transform: uppercase;
  padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper); font-weight: 700;
}
.letters::placeholder { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink-3); font-size: 1rem; }
.go { padding: 0 20px; border-radius: 10px; border: 0; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.go:hover { filter: brightness(1.15); }
.tilerow { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; margin-top: 12px; }
.tile {
  display: inline-grid; place-items: center; width: 40px; height: 44px; background: var(--tile); border: 1.5px solid var(--tile-edge);
  border-radius: 8px; box-shadow: 0 3px 0 var(--tile-shadow); font-weight: 800; font-size: 1.25rem; text-transform: uppercase; position: relative;
}
.tile small { position: absolute; right: 4px; bottom: 2px; font-size: .55rem; font-weight: 600; color: var(--ink-3); }
.tile.wild { background: var(--hint-soft); border-style: dashed; color: var(--ink-2); }
.tile.sm { width: 30px; height: 34px; font-size: .95rem; border-radius: 6px; box-shadow: 0 2px 0 var(--tile-shadow); }
.tile.sm small { font-size: .5rem; right: 3px; bottom: 1px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.btn { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .92rem; }
.btn:hover { background: var(--paper); }
.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.hintbtn { background: var(--hint-soft); border-color: transparent; color: var(--ink); }
.spacer { flex: 1; }

.filters summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--ink-2); padding: 8px 0; list-style: none; }
.filters summary::-webkit-details-marker { display: none; }
.filters summary::before { content: "+ "; }
.filters[open] summary::before { content: "– "; }
.filtergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 4px 0 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.field input, .field select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); font-size: .95rem; font-weight: 500; color: var(--ink); }
.field.check { flex-direction: row; align-items: center; align-self: end; gap: 8px; padding: 8px 0; }

/* AI helper */
.helper { display: flex; gap: 8px; margin-top: 12px; }
.helper input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); }
.helper .reply { font-size: .9rem; color: var(--ink-2); margin: 8px 2px 0; min-height: 1.2em; }

/* Status / hint */
.status { margin: 18px 0 8px; color: var(--ink-2); font-size: .95rem; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.status strong { color: var(--ink); font-size: 1.05rem; }
.hint { background: var(--hint-soft); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; display: none; }
.hint.show { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.hint h2 { margin: 0; font-size: 1rem; }
.hint p { margin: 0; color: var(--ink-2); font-size: .9rem; flex: 1; min-width: 160px; }
.hint .toolbar { margin: 0; }
.hint #hintlines { flex-basis: 100%; }
.hint #hintlines:empty { display: none; }
.hint .hintline { background: var(--surface); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 1rem; }
.hint .hintline.pending { color: var(--ink-3); }

/* Results */
.group { margin: 18px 0; }
.group h2 { font-size: 1rem; color: var(--ink-2); font-weight: 600; margin: 0 0 8px; display: flex; align-items: baseline; gap: 8px; }
.group h2 span { color: var(--ink-3); font-weight: 500; font-size: .9rem; }
.words { display: flex; flex-wrap: wrap; gap: 8px; }
.word {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 8px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--line); font-weight: 700; letter-spacing: .02em; text-decoration: none; font-size: 1rem; cursor: pointer;
}
.word:hover { border-color: var(--found); background: var(--found-soft); }
.word .pts { font-weight: 600; font-size: .78rem; color: var(--ink-3); background: var(--paper); padding: 2px 6px; border-radius: 6px; }
.word.common::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--found); }
.more { margin: 8px 0 0; }
.empty { color: var(--ink-2); padding: 24px 0; }
@media (prefers-reduced-motion: no-preference) {
  .word { animation: land .3s ease-out both; }
  @keyframes land { from { transform: translateY(6px) rotate(-2deg); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Insight popover */
.insight { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; max-width: 420px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(10,14,30,.2); color: var(--ink); }
.insight::backdrop { background: rgba(10, 14, 30, .35); }
.insight h3 { margin: 0 0 4px; font-size: 1.5rem; letter-spacing: .02em; display: flex; justify-content: space-between; align-items: center; }
.insight h3 .pts { font-size: .85rem; color: var(--ink-3); font-weight: 600; }
.insight .body { color: var(--ink-2); font-size: .98rem; margin: 6px 0 10px; }
.insight .body p { margin: 0 0 6px; }
.insight .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Ads */
.ad { display: grid; place-items: center; min-height: 100px; margin: 20px 0; }
.ad-label { font-size: .7rem; color: var(--ink-3); text-align: center; letter-spacing: .04em; }
.ad-box { width: 100%; min-height: 90px; border-radius: var(--radius-s); background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(128,128,128,.06) 10px 11px); border: 1px dashed var(--line); }
.ad-box.filled { background: none; border: 0; min-height: 0; }
.side { position: sticky; top: 16px; align-self: start; display: none; }
@media (min-width: 1120px) { .side { display: block; } }
.side .ad-box { min-height: 600px; }

/* Content */
.content { margin-top: 36px; }
.content h2 { font-size: 1.3rem; letter-spacing: -0.01em; margin: 28px 0 10px; }
.faq details { border-top: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq p { color: var(--ink-2); margin: 8px 0 0; }
.misspell { color: var(--ink-3); font-size: .85rem; margin-top: 24px; }
.prose p { color: var(--ink-2); max-width: 65ch; }

footer { margin: 48px 0 32px; color: var(--ink-3); font-size: .85rem; }
footer nav { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; }
footer a { text-decoration: none; color: var(--ink-2); }
footer p { margin: 0; max-width: 70ch; }

/* Consent */
.consent { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: none; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: 0 12px 30px rgba(10,14,30,.15); font-size: .9rem; }
.consent.show { display: flex; }
.consent span { flex: 1; min-width: 200px; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
.toast.show { opacity: 1; }
.notice { background: var(--found-soft); color: var(--found-ink); border-radius: 10px; padding: 8px 12px; font-size: .9rem; margin: 10px 0 0; display: none; }
.notice.show { display: block; }
@media (max-width: 480px) {
  body { font-size: 16px; }
  header.top { padding: 12px 0 4px; }
  .brand .text { display: none; }
  .topnav summary, .langsel { font-size: .9rem; padding-left: 10px; }
  .inputrow { flex-wrap: wrap; }
  .go { width: 100%; padding: 12px; }
  .tile { width: 34px; height: 38px; font-size: 1.05rem; }
  .hero { padding-top: 12px; }
}
