/* Quordle board. Moonlit tokens for the chrome; green/yellow are the ones every Wordle player reads (same as Waffle). */
:root { --qd-g: #6fb05c; --qd-y: #e9ba3a; --qd-on: #fff; --qd-x: #8e8ba8; --qd-cell: var(--cell); --qd-cell-ink: var(--ink); --qd-board: var(--surface); --qd-key: var(--surface-2); --qd-key-ink: var(--ink); --qd-dead: #cfcde0; --qd-dead-ink: #8a87a6; --qd-bad: #e2546f; }
[data-theme='dark'] { --qd-g: #3f9a3c; --qd-y: #c9a52e; --qd-x: #4a4868; --qd-cell: #2b2a5c; --qd-board: #1c1b3f; --qd-key: #3a3870; --qd-dead: #1f1e40; --qd-dead-ink: #5d5a86; --qd-bad: #ff7d94; }

.qd { width: 100%; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; --cs: 44px; --gap-b: 12px; --pad: 8px; --gap-c: 4px; --ds: calc(var(--cs) * .42); display: flex; flex-direction: column; gap: 10px; }

/* ---------- boards 2×2 ---------- */
.qd-boards { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-b); }
.qd-board { position: relative; background: var(--qd-board); border: 1px solid var(--line); border-radius: 12px; padding: var(--pad); display: flex; flex-direction: column; gap: 4px; transition: box-shadow .3s ease; }
.qd-board.ping { animation: qdping .9s ease; }
@keyframes qdping { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 30% { box-shadow: 0 0 0 4px var(--accent); } }
.qd-head { display: flex; align-items: center; gap: 6px; min-height: 18px; font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--ink-faint); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.qd-n { width: 18px; height: 18px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-soft); font-size: 11px; }
.qd-left { margin-left: auto; color: var(--ink-soft); transition: color .3s ease; }
.qd-left.one { color: var(--accent); animation: qdone .6s ease; }
@keyframes qdone { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.qd-slots { flex: 1 0 100%; display: flex; gap: 3px; }
.qd-slots i { flex: 1; text-align: center; font-style: normal; font-size: 11px; font-weight: 800; border-radius: 4px; background: var(--surface-2); color: var(--ink-faint); padding: 1px 0; }
.qd-slots i.g { background: var(--qd-g); color: var(--qd-on); }
.qd-slots i.h { background: var(--accent); color: var(--accent-ink); }
.qd-rows { position: relative; display: flex; flex-direction: column; gap: var(--gap-c); }
.qd-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap-c); height: var(--ds); transition: height .25s cubic-bezier(.3, 1, .4, 1); }
.qd-row.cur { height: var(--cs); }
.qd-c { display: grid; place-items: center; border-radius: 6px; background: var(--qd-cell); color: var(--qd-cell-ink); font-family: var(--display); font-weight: 800; font-size: calc(var(--ds) * .62); line-height: 1; text-transform: uppercase; box-shadow: inset 0 0 0 1px var(--line); transition: background-color .15s ease, color .15s ease, font-size .25s ease; }
.qd-row.idle .qd-c { background: transparent; box-shadow: inset 0 0 0 1px var(--line); opacity: .6; }
.qd-row.cur .qd-c { font-size: calc(var(--cs) * .52); border-radius: 8px; }
.qd-row.cur .qd-c.fill { box-shadow: inset 0 0 0 2px var(--line-strong); }
.qd-row.cur .qd-c.cursor { box-shadow: inset 0 0 0 2px var(--accent-2); animation: qdcur 1s ease-in-out infinite; }
@keyframes qdcur { 0%, 100% { box-shadow: inset 0 0 0 2px var(--accent-2); } 50% { box-shadow: inset 0 0 0 2px transparent; } }
.qd-row.cur .qd-c.bad { color: var(--qd-bad); }
.qd-c.pop { animation: qdpop .16s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes qdpop { 0% { transform: scale(1); } 50% { transform: scale(1.12); } 100% { transform: scale(1); } }
.qd-c.g, .qd-c.y, .qd-c.x { box-shadow: none; color: var(--qd-on); }
.qd-c.g { background: var(--qd-g); } .qd-c.y { background: var(--qd-y); } .qd-c.x { background: var(--qd-x); }
.qd-c.flip { animation: qdflip .32s ease-in-out; }
@keyframes qdflip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.qd-row.shake { animation: qdshake .35s ease-in-out; }
@keyframes qdshake { 0%, 100% { translate: 0; } 20% { translate: -5px 0; } 40% { translate: 5px 0; } 60% { translate: -3px 0; } 80% { translate: 3px 0; } }
/* solved board: a check over the unused rows */
.qd-done { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 10px; background: color-mix(in srgb, var(--qd-g) 14%, var(--qd-board)); color: var(--ink); animation: qdin .35s ease; pointer-events: none; }
.qd-done[hidden] { display: none; }
.qd-done .ck { width: 28px; height: 28px; border-radius: 50%; background: var(--qd-g); color: var(--qd-on); display: grid; place-items: center; }
.qd-done .ck svg { width: 18px; height: 18px; }
.qd-done .w { font-family: var(--display); font-weight: 800; font-size: 15px; letter-spacing: .1em; }
.qd-done small { font-size: 11px; color: var(--ink-soft); font-weight: 700; }
@keyframes qdin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
/* game over: every guessed row expands so the game can be read back */
.qd.over .qd-row.done { height: var(--cs); }
.qd.over .qd-row.done .qd-c { font-size: calc(var(--cs) * .52); border-radius: 8px; }
.qd.over .qd-row.idle { height: calc(var(--ds) * .6); }
.qd.over .qd-done { display: none; }
.qd-confetti { position: absolute; left: 0; top: -40px; width: 100%; height: calc(100% + 40px); pointer-events: none; z-index: 8; }

/* ---------- toast / hint ---------- */
.qd-toast { text-align: center; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 0; min-height: 18px; opacity: 0; transition: opacity .2s ease; }
.qd-toast.show { opacity: 1; }
.qd-toast.bad { color: var(--bad); }
.qd-hint { margin: 0 auto; max-width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-btn); padding: 10px 12px; font-size: 14px; color: var(--ink); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; line-height: 1.4; animation: qdin .25s ease; }
.qd-hint[hidden] { display: none; }
.qd-hint .ic { width: 22px; height: 22px; flex: none; color: var(--accent); } .qd-hint .ic svg { width: 22px; height: 22px; }
.qd-hint p { margin: 0; flex: 1 1 200px; }

/* ---------- keyboard with four quadrants ---------- */
.qd-kb { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 520px; margin: 4px auto 0; touch-action: manipulation; }
.qd-kr { display: flex; gap: 5px; justify-content: center; }
.qd-k { position: relative; flex: 1 1 0; min-width: 0; height: 50px; border: 0; border-radius: 6px; background: var(--qd-key); color: var(--qd-key-ink); font: inherit; font-weight: 800; font-size: 15px; padding: 0; overflow: hidden; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .03s ease, background-color .2s ease, color .2s ease; }
.qd-k:active { transform: scale(.93); }
.qd-k.wide { flex: 1.5 1 0; font-size: 12px; letter-spacing: .04em; }
.qd-k.wide svg { width: 22px; height: 22px; }
.qd-k b { position: relative; z-index: 1; font-weight: 800; text-shadow: 0 0 3px var(--qd-key), 0 0 3px var(--qd-key); }
/* one cell per board, two columns, same order as the boards (1 2 / 3 4 / …) */
.qd-q { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(var(--rows, 2), 1fr); }
.qd-q i { display: block; }
.qd-q i.g { background: var(--qd-g); } .qd-q i.y { background: var(--qd-y); }
.qd-k.u-g { background: var(--qd-g); color: var(--qd-on); } .qd-k.u-y { background: var(--qd-y); color: var(--qd-on); }
.qd-k.dead { background: var(--qd-dead); color: var(--qd-dead-ink); }
@media (max-width: 400px) { .qd-k { height: 46px; font-size: 14px; } .qd-kr { gap: 4px; } .qd-k.wide { font-size: 11px; } }

/* ---------- eight boards: compact layout ---------- */
.qd-sv { display: none; align-items: center; gap: 6px; color: var(--ink); }
.qd-sv .ck { width: 16px; height: 16px; border-radius: 50%; background: var(--qd-g); color: var(--qd-on); display: grid; place-items: center; flex: none; }
.qd-sv .ck svg { width: 11px; height: 11px; }
.qd-sv .w { font-family: var(--display); font-weight: 800; font-size: 13px; letter-spacing: .08em; }
.qd-sv small { font-size: 10px; color: var(--ink-soft); font-weight: 700; }
.qd-compact { --ds: calc(var(--cs) * .36); gap: 8px; }
.qd-compact .qd-boards { align-items: start; } /* a folded (solved) board stays short beside a tall open one */
.qd-compact .qd-rows { gap: 2px; }
.qd-compact .qd-row.done { margin-bottom: 1px; }
.qd-compact .qd-row.idle { display: block; height: 2px; border-radius: 1px; background: var(--line); opacity: .45; } /* one hairline per unused guess */
.qd-compact .qd-row.idle .qd-c { display: none; }
.qd-compact .qd-board.is-solved .qd-rows { display: none; }
.qd-compact .qd-board.is-solved .qd-sv { display: inline-flex; }
.qd-compact .qd-board.is-solved .qd-done { display: none; }
.qd-compact .qd-board.is-solved .qd-head { min-height: 22px; }
.qd-compact.over .qd-sv { display: none; }
.qd-compact.over .qd-row.idle { display: none; }
.qd-compact .qd-head { font-size: 10px; }
.qd-compact .qd-n { width: 16px; height: 16px; font-size: 10px; }
/* board strip: number + words left per board, sticks under the site header while the boards scroll */
.qd-strip { position: sticky; top: calc(var(--stick, 0px) + 6px); z-index: 6; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 6px; margin: -6px -6px 0; background: var(--board-bg); border-radius: 10px; }
.qd-chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); border-radius: 8px; padding: 4px 0 3px; font: inherit; font-size: 11px; font-weight: 800; line-height: 1.1; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; font-variant-numeric: tabular-nums; min-width: 0; -webkit-tap-highlight-color: transparent; transition: background-color .2s ease, color .2s ease; }
.qd-chip b { font-size: 10px; color: var(--ink-faint); }
.qd-chip .n { min-height: 13px; }
.qd-chip.one { color: var(--accent); border-color: var(--accent); }
.qd-chip.done { background: color-mix(in srgb, var(--qd-g) 22%, var(--surface)); color: var(--ink); border-color: transparent; }
.qd-chip.done b { color: var(--ink-soft); }
.qd-chip.pop { animation: qdone .5s ease; }
.qd-compact .qd-kb { position: sticky; bottom: 6px; z-index: 6; background: var(--board-bg); padding-top: 6px; }
@media (max-width: 400px) { .qd-chip { font-size: 10px; border-radius: 6px; } .qd-strip { gap: 3px; } }

/* ---------- eight-board win ---------- */
.qd-board.won { animation: qdwon .8s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes qdwon { 0% { transform: none; box-shadow: 0 0 0 0 transparent; } 35% { transform: translateY(-3px) scale(1.03); box-shadow: 0 0 0 4px var(--qd-y), 0 8px 24px color-mix(in srgb, var(--qd-y) 45%, transparent); background: color-mix(in srgb, var(--qd-g) 22%, var(--qd-board)); } 100% { transform: none; box-shadow: 0 0 0 0 transparent; } }
.qd-compact.glow .qd-boards { animation: qdglow 1.6s ease; }
@keyframes qdglow { 0% { box-shadow: 0 0 0 0 transparent; } 25% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--qd-y) 70%, transparent), 0 0 60px 10px color-mix(in srgb, var(--qd-y) 35%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
/* headline: fixed to the viewport (the boards may be scrolled), a dark card so it reads on both themes */
.qd-win { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; pointer-events: none; text-align: center; padding: 16px; }
.qd-win[hidden] { display: none; }
.qd-win > div { background: rgba(22, 20, 54, .95); border: 2px solid var(--qd-y); border-radius: 22px; padding: 22px 36px 20px; box-shadow: 0 0 0 6px color-mix(in srgb, var(--qd-y) 35%, transparent), 0 24px 70px rgba(0, 0, 0, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.qd-win b { display: block; font-family: var(--display); font-weight: 800; font-size: clamp(38px, 12vw, 64px); line-height: 1; letter-spacing: .01em; background: linear-gradient(180deg, #fff6d0 0%, #f4c94a 50%, #d4921a 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .35)); }
.qd-win small { display: block; margin-top: 10px; font-size: 14px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #fff; opacity: .92; }
.qd-win.in > div { animation: qdwinin .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes qdwinin { 0% { opacity: 0; transform: scale(.3) rotate(-8deg); } 100% { opacity: 1; transform: none; } }
.qd-win.out > div { animation: qdwinout .45s ease forwards; }
@keyframes qdwinout { to { opacity: 0; transform: translateY(-24px) scale(1.1); } }
.qd-confetti.fixed { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 59; }
@media (prefers-reduced-motion: reduce) { .qd-board.won, .qd-compact.glow .qd-boards, .qd-win.in > div { animation: none; } }

/* ---------- static mini rows (review, how to play, archive) ---------- */
.qd-mini { display: inline-grid; grid-template-columns: repeat(5, 26px); gap: 3px; vertical-align: middle; }
.qd-mini i { height: 26px; display: grid; place-items: center; border-radius: 5px; font-style: normal; font-family: var(--display); font-weight: 800; font-size: 13px; color: var(--qd-on); background: var(--qd-x); }
.qd-mini i.g { background: var(--qd-g); } .qd-mini i.y { background: var(--qd-y); }
.qd-mini.lg { grid-template-columns: repeat(5, 40px); } .qd-mini.lg i { height: 40px; font-size: 20px; border-radius: 7px; }

/* ---------- page bits ---------- */
.qd-page { width: 100%; }
.qd-page .board-wrap { padding: 12px; }
.qd-page .gp-bar .qd-left-n { font-family: var(--display); font-weight: 700; font-size: 22px; }
.qd-page .gp-bar .qd-left-n small { font-family: var(--body); font-size: 12px; color: var(--ink-faint); font-weight: 600; margin-left: 6px; letter-spacing: .08em; }
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon { position: relative; }
.btn-icon .cnt { position: absolute; right: -5px; top: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.btn-icon .cnt:empty { display: none; }
.snd-off .ic-on, .btn-icon:not(.snd-off) .ic-off { display: none; }
.q-settings { position: static; }
.gp-bar { position: relative; }
.q-pop { position: absolute; right: 0; top: calc(100% - 4px); max-width: calc(100vw - 32px); z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); box-shadow: var(--shadow-hover); padding: 6px 4px; min-width: 260px; }
.q-pop[hidden] { display: none; }
.q-pop label { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.q-pop label small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.q-pop .sw { width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; transition: background .15s ease; }
.q-pop .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.q-pop input { position: absolute; opacity: 0; pointer-events: none; }
.q-pop input:checked + .sw { background: var(--good); }
.q-pop input:checked + .sw::after { transform: translateX(16px); }
.q-pop input:focus-visible + .sw { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.q-meta { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 700; color: var(--ink-soft); flex-wrap: wrap; }
.q-meta .pill { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-variant-numeric: tabular-nums; }
.q-pick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 12px; }
.q-pick button { border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.q-pick button[aria-pressed='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* result card: the four words with their guess number, missed ones in red */
.qd-result .words { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.qd-page[data-boards='8'] .qd-result .words { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 480px) { .qd-page[data-boards='8'] .qd-result .words { grid-template-columns: 1fr 1fr; } }
.qd-page[data-boards='8'] .qd-review .detail .per { grid-template-columns: 1fr 1fr; }
.qd-result .words a, .qd-result .words span.w { font-family: var(--display); font-weight: 800; letter-spacing: .08em; text-decoration: none; color: var(--good); }
.qd-result .words .miss a, .qd-result .words .miss span.w { color: var(--bad); }
.qd-result .words small { color: var(--ink-soft); font-weight: 700; margin-left: 6px; }
.solved.qd-result { flex-wrap: wrap; }
.solved.qd-result > div:first-of-type { flex: 1 1 240px; }

/* review strip */
.qd-review { margin: 8px 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.qd-review h2 { margin: 0 0 4px; font-size: 18px; }
.qd-review .lede { margin: 0 0 10px; color: var(--ink-soft); font-size: 14px; }
.qd-review .steps { display: flex; flex-wrap: wrap; gap: 6px; }
.qd-review .step { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 10px; padding: 6px 8px; font: inherit; font-size: 12px; font-weight: 800; letter-spacing: .06em; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.qd-review .step i { font-style: normal; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; background: var(--good); }
.qd-review .step.ok i { background: var(--ink-faint); } .qd-review .step.weak i { background: var(--bad); }
.qd-review .step[aria-pressed='true'] { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2); }
.qd-review .sum { margin: 10px 0 0; font-size: 14px; color: var(--ink-soft); }
.qd-review .detail { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; display: grid; gap: 10px; }
.qd-review .detail .per { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.qd-review .detail .per div { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.qd-review .detail .per b { color: var(--ink-faint); font-size: 11px; width: 14px; }
.qd-review .detail .per small { color: var(--ink-soft); }
.qd-review .detail p { margin: 0; }
.qd-review .legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink-soft); margin: 8px 0 0; flex-wrap: wrap; }

/* stats distribution */
.qd-dist { display: grid; gap: 4px; margin-top: 10px; }
.qd-dist .bar { display: grid; grid-template-columns: 24px 1fr 28px; align-items: center; gap: 8px; font-size: 12px; }
.qd-dist .bar i { display: block; height: 14px; border-radius: 4px; background: var(--accent-2); min-width: 2px; }
.qd-dist .bar b { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .qd-page .board-wrap { padding: 8px; } }
