/* Waffle board. Moonlit tokens for the chrome; the tile colours are the ones every Waffle player already reads
 * (green = home, yellow = in this row/column), so those stay close to the original game's. */
:root { --wf-g: #6fb05c; --wf-y: #e9ba3a; --wf-on: #fff; --wf-t: var(--cell); --wf-t-ink: var(--ink); --wf-hole: color-mix(in srgb, var(--surface-2) 60%, var(--board-bg)); --wf-dead: #1b1a3f; --wf-dead-ink: #f6f2ff; --wf-hint: var(--accent-2); }
[data-theme='dark'] { --wf-g: #3f9a3c; --wf-y: #c9a52e; --wf-t: #2b2a5c; --wf-t-ink: var(--ink); --wf-hole: #12112a; --wf-dead: #000; --wf-dead-ink: #f6f7f8; }

.wf { width: 100%; position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; --ts: 64px; --gap: 5px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- word chips (three across, three down; light up as words complete) ---------- */
.wf-words { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; font-size: 12px; }
.wf-words .lbl { color: var(--ink-faint); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; }
.wf-words .row { display: flex; gap: 6px; min-width: 0; }
.wf-words .chip { flex: 1 1 0; min-width: 0; text-align: center; padding: 4px 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-faint); font-family: var(--display); font-weight: 800; letter-spacing: .12em; font-size: 12px; white-space: nowrap; overflow: hidden; transition: background-color .4s ease, color .4s ease, transform .3s cubic-bezier(.3, 1.4, .5, 1); }
.wf-words .chip.lit { background: var(--accent); color: var(--accent-ink); border-color: transparent; letter-spacing: .14em; animation: wfchip .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes wfchip { 0% { transform: scale(1); } 45% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ---------- board ---------- */
.wf-stage { position: relative; width: min(100%, 440px); margin: 0 auto; }
.wf-board { position: relative; width: 100%; aspect-ratio: 1; touch-action: none; }
.wf-hole { position: absolute; width: var(--ts); height: var(--ts); border-radius: 14%; background: var(--wf-hole); box-shadow: inset 0 2px 4px rgba(27, 26, 63, .06); }
.wf-t { position: absolute; left: 0; top: 0; width: var(--ts); height: var(--ts); border-radius: 13%; display: grid; place-items: center; padding-top: 1%; background: var(--wf-t); color: var(--wf-t-ink); font-family: var(--display); font-weight: 800; font-size: calc(var(--ts) * .5); line-height: 1; text-transform: uppercase; cursor: grab; border-bottom: 4px solid rgba(0, 0, 0, .1); box-shadow: 0 1px 2px rgba(27, 26, 63, .06); transition: transform .3s cubic-bezier(.19, 1, .22, 1), background-color 1s cubic-bezier(.19, 1, .22, 1), color .6s ease, box-shadow .2s ease; will-change: transform; -webkit-tap-highlight-color: transparent; outline: none; }
.wf-t.no-t { transition: none !important; }
.wf-t.g { background: var(--wf-g); color: var(--wf-on); cursor: default; }
.wf-t.y { background: var(--wf-y); color: var(--wf-on); }
.wf-t.fly { z-index: 3; }
.wf-t.sel { z-index: 4; box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(27, 26, 63, .18); }
.wf-t.sel:not(.drag) { transform: var(--xy) scale(1.06) !important; }
.wf-t.drag { z-index: 6; cursor: grabbing; box-shadow: 2px 6px 14px rgba(0, 0, 0, .18), 0 1px 2px rgba(0, 0, 0, .25); }
.wf-t.over { box-shadow: 0 0 0 3px var(--accent); }
.wf-t.pop { animation: wfpop .42s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes wfpop { 0% { scale: 1; } 40% { scale: 1.15; } 100% { scale: 1; } }
.wf-t.shake { animation: wfshake .3s ease-in-out; box-shadow: 0 0 0 3px var(--bad); }
@keyframes wfshake { 0%, 100% { translate: 0; } 20% { translate: -4px 0; } 40% { translate: 4px 0; } 60% { translate: -3px 0; } 80% { translate: 3px 0; } }
.wf-t:focus-visible { box-shadow: 0 0 0 3px var(--accent-2); }
@media (hover: hover) { .wf-t:not(.g):not(.drag):hover { filter: brightness(.97); } }

/* a completed word: a sheen sweeps across it */
.wf-flash { position: absolute; border-radius: 10px; pointer-events: none; z-index: 5; overflow: hidden; }
.wf-flash::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 20%, rgba(255, 255, 255, .55) 50%, transparent 80%); transform: translateX(-100%); animation: wfsheen .55s ease-out forwards; }
.wf-flash.down::after { background: linear-gradient(170deg, transparent 20%, rgba(255, 255, 255, .55) 50%, transparent 80%); transform: translateY(-100%); animation-name: wfsheenv; }
@keyframes wfsheen { to { transform: translateX(100%); } }
@keyframes wfsheenv { to { transform: translateY(100%); } }

/* hint: dim the rest, ring the two tiles, a swap badge between them */
.wf-stage.hinting .wf-t:not(.hl) { opacity: .45; }
.wf-t.hl { z-index: 5; opacity: 1; box-shadow: 0 0 0 3px var(--wf-hint), 0 0 0 7px color-mix(in srgb, var(--wf-hint) 25%, transparent); animation: wfhl 1.1s ease-in-out infinite; }
@keyframes wfhl { 0%, 100% { scale: 1; } 50% { scale: 1.05; } }
.wf-badge { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: var(--wf-hint); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 15px; z-index: 7; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); pointer-events: none; }
.wf-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: wfin .25s cubic-bezier(.3, 1.2, .5, 1); }
.wf-hint .ic { width: 22px; height: 22px; flex: none; color: var(--wf-hint); }
.wf-hint .ic svg { width: 22px; height: 22px; }
.wf-hint p { margin: 0; flex: 1 1 200px; }
.wf-hint .acts { display: flex; gap: 6px; flex: none; margin-left: auto; }
@keyframes wfin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* toast under the board */
.wf-toast { text-align: center; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: -4px 0 0; min-height: 18px; }
.wf-toast.show { animation: wftoast 1.6s ease both; }
.wf-toast.bad { color: var(--bad); }
.wf-toast.good { color: var(--good); }
@keyframes wftoast { 0% { opacity: 0; transform: translateY(4px); } 12% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* win: the wave, then the glow; lose: the board goes dark and shows the answer */
.wf-t.wave { animation: wfwave .6s cubic-bezier(.3, 1.2, .5, 1) both; animation-delay: var(--d, 0s); }
@keyframes wfwave { 0% { translate: 0; } 30% { translate: 0 -18px; } 65% { translate: 0 5px; } 85% { translate: 0 -6px; } 100% { translate: 0; } }
.wf-stage::after { content: ""; position: absolute; inset: -10%; border-radius: 50%; pointer-events: none; z-index: 8; background: radial-gradient(circle, rgba(255, 236, 190, .7), rgba(233, 181, 74, .22) 45%, transparent 70%); opacity: 0; }
.wf-stage.glow::after { animation: wfglow 2s ease-out both; }
@keyframes wfglow { 0% { opacity: 0; transform: scale(.7); } 22% { opacity: .85; transform: scale(1); } 100% { opacity: 0; transform: scale(1.15); } }
[data-theme='dark'] .wf-stage::after { background: radial-gradient(circle, rgba(242, 194, 90, .45), rgba(154, 148, 255, .2) 45%, transparent 70%); mix-blend-mode: screen; }
.wf-board.dead .wf-t { background: var(--wf-dead); color: var(--wf-dead-ink); cursor: default; border-bottom-color: transparent; }
.wf-board.dead .wf-t.g { background: color-mix(in srgb, var(--wf-g) 55%, var(--wf-dead)); }
.wf.locked .wf-t { cursor: default; }
.wf-fx { position: absolute; inset: -60px 0 -30px; width: 100%; height: calc(100% + 90px); pointer-events: none; z-index: 30; }

/* ---------- toolbar bits ---------- */
.wf-swaps { display: inline-flex; align-items: baseline; gap: 6px; }
.wf-swaps .n { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: center; display: inline-block; transition: color .3s ease; }
.wf-swaps .n.low { color: var(--bad); }
.wf-swaps .n.bump { animation: wfbump .3s ease; }
@keyframes wfbump { 40% { transform: scale(1.2); } }
.wf-swaps small { font-family: var(--body); font-size: 11px; color: var(--ink-faint); font-weight: 700; letter-spacing: .08em; }
.wf-stars { display: inline-flex; gap: 2px; font-size: 18px; line-height: 1; color: var(--line-strong); letter-spacing: 0; }
.wf-stars i { font-style: normal; transition: color .35s ease, transform .35s cubic-bezier(.3, 1.6, .5, 1); }
.wf-stars i.on { color: var(--accent); }
.wf-stars i.drop { animation: wfdrop .4s ease; }
@keyframes wfdrop { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }
.wf-page.zen .wf-stars { display: none; }

/* ---------- result + review ---------- */
.wf-result .btn { white-space: nowrap; }
.wf-review { margin: 0 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 14px; font-size: 14px; animation: wfin .25s ease; }
.wf-review h2 { margin: 0; font-size: 18px; }
.wf-review .lede { margin: 2px 0 8px; color: var(--ink-soft); font-size: 13px; }
.wf-review .steps { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 8px; }
.wf-review .step { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--good); font-weight: 900; font-size: 15px; display: grid; place-items: center; cursor: pointer; font-family: var(--body); padding: 0; }
.wf-review .step.x { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.wf-review .step[aria-pressed='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.wf-review .sum { font-weight: 700; margin: 0 0 6px; }
.wf-review .detail { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.wf-review .detail p { margin: 0 0 6px; flex: 1 1 200px; }
.wf-review .detail .muted { font-size: 13px; }

/* static mini board (review, how to play, archive) */
.wf-mini { display: grid; grid-template-columns: repeat(5, var(--ms, 34px)); gap: 3px; flex: none; }
.wf-mini span { width: var(--ms, 34px); height: var(--ms, 34px); border-radius: 18%; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: calc(var(--ms, 34px) * .5); text-transform: uppercase; background: var(--wf-t); color: var(--wf-t-ink); border-bottom: 2px solid rgba(0, 0, 0, .1); }
.wf-mini span.h { background: var(--wf-hole); border-bottom: 0; }
.wf-mini span.g { background: var(--wf-g); color: var(--wf-on); }
.wf-mini span.y { background: var(--wf-y); color: var(--wf-on); }
.wf-mini span.x { box-shadow: 0 0 0 2px var(--bad); }
.wf-mini span.hl { box-shadow: 0 0 0 3px var(--wf-hint); }
.wf-mini span.x.hl { box-shadow: 0 0 0 2px var(--bad), 0 0 0 5px var(--wf-hint); }
.wf-how .wf-mini { --ms: 40px; margin: 8px 0 16px; }

/* ---------- page bits (same look as the other games) ---------- */
.wf-page .board-wrap { padding: 14px; overflow: clip; }
.wf-result { flex-wrap: wrap; }
.wf-result > div { flex: 1 1 200px; min-width: 0; }
@media (max-width: 480px) { .wf-result > div { flex-basis: calc(100% - 52px); } .wf-result .btn { margin-left: 0; } .wf-result .btn-primary { margin-left: auto; } }
.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-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); }
.q-pick button.zen[aria-pressed='true'] { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
@media (max-width: 480px) { .wf-page .board-wrap { padding: 8px; } .wf-page .wrap-game { padding: 0 10px; } .wf-words .chip { font-size: 11px; letter-spacing: .08em; padding: 4px 2px; } .wf-swaps .n { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { .wf-t.pop, .wf-t.shake, .wf-t.hl, .wf-t.wave, .wf-flash::after, .wf-stage.glow::after, .wf-words .chip.lit, .wf-swaps .n.bump, .wf-stars i.drop { animation: none !important; } }
