/* Tiles board. Tokens from style.css (Moonlit). Ten tints (--tt0…9, Lantern bases), ten saturated colours
 * (--tc0…9, Terrazzo + Lantern glyphs), tile background (--tile-bg, also the Ink cut-out colour). */
:root {
  --tt0: #fdf0d1; --tt1: #e6e2fb; --tt2: #d9f3ea; --tt3: #fde2df; --tt4: #e2eefb; --tt5: #f3e4f7; --tt6: #eaf4d3; --tt7: #e9def7; --tt8: #fde9d6; --tt9: #e3e6ef;
  --tc0: #d9a12e; --tc1: #6d66e0; --tc2: #1f9e8a; --tc3: #e0644f; --tc4: #3b8fd9; --tc5: #d2559a; --tc6: #6fa83a; --tc7: #8b5fbf; --tc8: #ec8a4a; --tc9: #5f6b8a;
  --tt-c: #c3bde6; --tile-bg: #ffffff; --tl-empty: #f1eff8; --tl-dim: rgba(27, 26, 63, .32);
}
[data-theme='dark'] {
  --tt0: #4a3d1c; --tt1: #33306b; --tt2: #1e4a40; --tt3: #52302c; --tt4: #23395c; --tt5: #4a2a48; --tt6: #34461e; --tt7: #3f2f5a; --tt8: #523a24; --tt9: #333a52;
  --tc0: #f2c25a; --tc1: #9a94ff; --tc2: #4cc9b3; --tc3: #ff8a76; --tc4: #6cb2ff; --tc5: #f07cbd; --tc6: #9ad45c; --tc7: #b48ae6; --tc8: #ffa66b; --tc9: #9aa5c4;
  --tt-c: #45428a; --tile-bg: #22214a; --tl-empty: #1a193a; --tl-dim: rgba(0, 0, 0, .45);
}

.tl { width: 100%; position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; --ts: 64px; --cols: 5; --gap: 6px; }
.tl-stage { position: relative; width: fit-content; margin: 0 auto; }
.tl-board { display: grid; grid-template-columns: repeat(var(--cols), var(--ts)); gap: var(--gap); position: relative; padding: 2px; }
.tl-board:focus-visible { outline: none; }

/* one tile */
.tl-t { width: var(--ts); height: var(--ts); border-radius: 12px; background: var(--tile-bg); border: 0; padding: 0; margin: 0; display: block; position: relative; cursor: pointer; box-shadow: 0 1px 2px rgba(27, 26, 63, .08), inset 0 0 0 1px var(--line); transition: transform .14s cubic-bezier(.3, 1.4, .5, 1), box-shadow .14s ease, background-color .3s ease; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[data-theme='dark'] .tl-t { box-shadow: 0 1px 2px rgba(0, 0, 0, .3), inset 0 0 0 1px var(--line-strong); }
.tl-t:focus-visible { box-shadow: 0 0 0 3px var(--accent-2); }
.tl-t:hover:not(.empty):not(.locked):not(.cur) { transform: translateY(-1px); }
.tl-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 12px; overflow: hidden; }
.tl-l { transform-box: view-box; transform-origin: 50% 50%; }
.tl-t.cur { transform: scale(1.06); z-index: 2; box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(27, 26, 63, .16); }
[data-theme='dark'] .tl-t.cur { box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(0, 0, 0, .5); }
.tl-t.empty { background: var(--tl-empty); box-shadow: inset 0 0 0 1px var(--line); cursor: default; }
.tl-t.empty .tl-art { display: none; }
.tl-t.locked { cursor: default; }

/* a matched layer shrinks and fades out; a cleared tile pops down to empty */
.tl-l.out { animation: tlout .2s ease-in forwards; }
@keyframes tlout { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.35); } }
.tl-t.pop { animation: tlpop .26s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes tlpop { 0% { transform: scale(1); } 45% { transform: scale(.9); } 100% { transform: scale(1); } }
.tl-t.shake { animation: tlshake .26s ease-in-out; box-shadow: 0 0 0 3px var(--bad); }
@keyframes tlshake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.tl-t.cur.shake { transform: scale(1.06); }

/* hint: dim everything but the two tiles; the shared layer pulses */
.tl-stage.hinting .tl-t:not(.hl) { opacity: .4; }
.tl-t.hl { z-index: 3; box-shadow: 0 0 0 3px var(--accent-2), 0 8px 18px rgba(27, 26, 63, .16); animation: tlhl 1s ease-in-out infinite; }
@keyframes tlhl { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.tl-t.hl.cur { animation: none; transform: scale(1.06); }
.tl-t.hl .tl-l.hl-l { animation: tlhll .8s ease-in-out infinite; }
@keyframes tlhll { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
.tl-hint { margin: 12px auto 0; 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: hintin .25s cubic-bezier(.3, 1.2, .5, 1); }
.tl-hint[hidden] { display: none; }
.tl-hint .ic { width: 22px; height: 22px; flex: none; color: var(--accent-2); }
.tl-hint .ic svg { width: 22px; height: 22px; }
.tl-hint p { margin: 0; flex: 1 1 200px; }
.tl-hint .acts { display: flex; gap: 6px; flex: none; margin-left: auto; }
@keyframes hintin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

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

/* win: empty cells light up in order, glow + confetti */
.tl-t.lit { animation: tllit .5s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: var(--d, 0s); }
@keyframes tllit { 0% { transform: scale(1); background-color: var(--tl-empty); } 40% { transform: scale(1.06); background-color: var(--accent); } 100% { transform: scale(1); background-color: var(--solved-bg); } }
.tl-board.won.quiet .tl-t { animation: none; background-color: var(--solved-bg); }
.tl-stage::after { content: ""; position: absolute; inset: -12%; border-radius: 50%; pointer-events: none; z-index: 6; background: radial-gradient(circle, rgba(255, 236, 190, .75), rgba(233, 181, 74, .25) 45%, transparent 70%); opacity: 0; }
.tl-stage.glow::after { animation: tlglow 2s ease-out both; }
@keyframes tlglow { 0% { opacity: 0; transform: scale(.7); } 22% { opacity: .85; transform: scale(1); } 100% { opacity: 0; transform: scale(1.15); } }
[data-theme='dark'] .tl-stage::after { background: radial-gradient(circle, rgba(242, 194, 90, .5), rgba(154, 148, 255, .2) 45%, transparent 70%); mix-blend-mode: screen; }
.tl-fx { position: absolute; inset: -60px -30px -30px; width: calc(100% + 60px); height: calc(100% + 90px); pointer-events: none; z-index: 30; }

/* combo readout in the toolbar */
.tl-combo { display: inline-flex; align-items: baseline; gap: 6px; }
.tl-combo .n { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; display: inline-block; min-width: 1.2em; text-align: center; }
.tl-combo .n.bump { animation: tlbump .28s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes tlbump { 0% { transform: scale(1); } 45% { transform: scale(1.35); color: var(--accent); } 100% { transform: scale(1); } }
.tl-combo .n.drop { animation: tldrop .35s ease-in; color: var(--bad); }
@keyframes tldrop { 0% { transform: translateY(-4px); } 60% { transform: translateY(3px); } 100% { transform: none; } }
.tl-combo small { font-family: var(--body); font-size: 11px; color: var(--ink-faint); font-weight: 700; letter-spacing: .08em; }
.tl-page.zen .tl-combo, .tl-page.zen .q-meta .longest { display: none; }

/* layer breakdown (how to play) */
.tl-sets { display: grid; gap: 18px; margin: 14px 0 22px; }
.tl-set { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.tl-set h3 { margin: 0 0 2px; font-size: 18px; }
.tl-set p { margin: 0 0 10px; color: var(--ink-soft); font-size: 14px; }
.tl-set .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tl-set .row b { flex: 0 0 74px; font-size: 12px; color: var(--ink-faint); letter-spacing: .06em; text-transform: uppercase; }
.tl-set .sw { width: 40px; height: 40px; border-radius: 9px; background: var(--tile-bg); box-shadow: inset 0 0 0 1px var(--line); position: relative; overflow: hidden; flex: none; }
.tl-set .sw .tl-art { border-radius: 9px; }
.tl-set .row.sum .sw { width: 52px; height: 52px; border-radius: 11px; }
.tl-set .row.sum .eq { font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--ink-faint); padding: 0 4px; }

/* page bits (same look as the other games) */
.tl-page .board-wrap { padding: 14px; }
.tl-demo { margin: 14px 0 6px; }
.tl-demo-board .tl { --ts: 56px; }
.tl-demo-note { text-align: center; }
.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: 240px; }
.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 .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); }
.q-pick button.zen[aria-pressed='true'] { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.tl-page .gp-bar .t { font-size: 18px; }
@media (max-width: 480px) { .tl-page .board-wrap { padding: 8px; } .tl-page .wrap-game { padding: 0 10px; } .tl { --gap: 5px; } }
@media (prefers-reduced-motion: reduce) { .tl-l.out, .tl-t.pop, .tl-t.shake, .tl-t.hl, .tl-t.hl .tl-l.hl-l, .tl-t.lit, .tl-stage.glow::after, .tl-combo .n.bump, .tl-combo .n.drop { animation: none !important; } }
