/* Letterpile daily games. Loaded only on the games pages and the home page (after style.css),
   using its tokens: the Night Edition palette, tiles and panels. */

/* ---------- page frame ---------- */
.game-layout { padding: 24px 16px 56px; }
.game-layout .content { max-width: 1080px; margin: 0 auto; }
.game-card { border-top: 10px solid var(--mint); padding: 22px; }
.game-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.game-head .page-title { margin: 0; }
.game-meta { margin: 0; color: var(--muted); font-size: .95rem; display: flex; flex-wrap: wrap; gap: 0 8px; }
.game-meta time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.game-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; padding: 10px 14px; border-radius: 16px; background: var(--surface-2); border: 2px solid var(--outline); font-weight: 700; }
.game-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; min-height: 44px; }
.game-msg { font-weight: 700; min-height: 1.6em; }
.game-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.game-timer { font: 800 1.1rem/1 var(--font-display); font-variant-numeric: tabular-nums; min-width: 4.5ch; }
.come-back { text-align: center; padding: 32px 8px; }
.come-back .big { font: 800 1.8rem/1.2 var(--font-display); margin: 0 0 8px; }
.game-done { margin-top: 16px; padding: 16px; border-radius: 18px; background: var(--surface-2); border: 2px solid var(--line); }
.game-done h2 { margin: 0 0 6px; font-size: 1.4rem; }
.game-done p { margin: 0 0 12px; }

/* ---------- hub cards and archive ---------- */
.game-cards { list-style: none; margin: 18px 0 8px; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.game-tile { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 22px; background: var(--c); color: var(--tile-ink); border: 2px solid transparent; box-shadow: var(--shadow); transition: transform .15s ease; }
.game-tile:hover { transform: translateY(-2px); }
.game-tile .top { display: flex; align-items: center; gap: 12px; }
.game-tile h2, .game-tile h3 { margin: 0; font-size: 1.3rem; }
.game-tile a { color: inherit; text-decoration: none; }
.game-tile a::after { content: ""; position: absolute; inset: 0; border-radius: 22px; }
.game-tile a:focus-visible { outline: none; }
.game-tile:has(a:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.game-tile p { margin: 0; font-size: .98rem; }
.game-tile .game-status { margin-top: auto; font-weight: 800; font-size: .9rem; }
.game-tile[data-state="solved"] .game-status::before, .game-tile[data-state="lost"] .game-status::before { content: ""; }
:root:not([data-theme="light"]) .game-tile { background: var(--surface); color: var(--text); border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 12px 28px -12px var(--c); }
:root[data-theme="dark"] .game-tile { background: var(--surface); color: var(--text); border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 12px 28px -12px var(--c); }
:root[data-theme="light"] .game-tile { background: var(--c); color: var(--tile-ink); border-color: transparent; box-shadow: var(--shadow); }
.game-archive { display: grid; gap: 4px 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.game-archive h3 { margin: 12px 0 4px; font-size: 1.05rem; }
.game-archive ul { margin: 0; padding-left: 1.1em; }
.game-archive li { margin: 2px 0; }
.home-games .section-lede time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }

/* ---------- Daily Word ---------- */
.word-game { max-width: 520px; margin: 0 auto; }
.dw-board { display: grid; gap: 6px; justify-content: center; margin: 4px 0 16px; }
.dw-row { display: grid; grid-template-columns: repeat(5, var(--dw, 58px)); gap: 6px; }
.dw-tile { display: grid; place-items: center; height: var(--dw, 58px); border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--text); font: 800 calc(var(--dw, 58px) * .5)/1 var(--font-display); text-transform: uppercase; position: relative; }
.dw-tile.filled { border-color: var(--field); animation: pop .12s ease-out; }
.dw-tile.m-g, .dw-tile.m-y, .dw-tile.m-b { color: #fff; border-color: transparent; box-shadow: inset 0 -3px 0 rgb(0 0 0 / .2); }
.dw-tile.m-b { background: #5A5F78; }
.dw-tile.m-y { background: #8a6a00; }
.dw-tile.m-g { background: #2e6b3a; }
.dw-tile.m-y::after, .dw-tile.m-g::after { position: absolute; right: 5px; top: 3px; font-size: 13px; line-height: 1; }
.dw-tile.m-y::after { content: "•"; }
.dw-tile.m-g::after { content: "✓"; }
.dw-row.reveal .dw-tile { animation: flip .4s ease both; }
.dw-row.reveal .dw-tile:nth-child(2) { animation-delay: .08s; } .dw-row.reveal .dw-tile:nth-child(3) { animation-delay: .16s; }
.dw-row.reveal .dw-tile:nth-child(4) { animation-delay: .24s; } .dw-row.reveal .dw-tile:nth-child(5) { animation-delay: .32s; }
.dw-row.shake { animation: shake .35s ease; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pop { from { transform: scale(.9); } to { transform: scale(1); } }
.wkeys { display: grid; gap: 6px; user-select: none; }
.krow { display: flex; gap: 5px; justify-content: center; }
.key { flex: 1 1 0; max-width: 46px; min-width: 0; min-height: 54px; padding: 0; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text); font: 800 1.05rem/1 var(--font-display); text-transform: uppercase; cursor: pointer; box-shadow: inset 0 -3px 0 rgb(0 0 0 / .15); touch-action: manipulation; }
.key.wide { flex: 1.6 1 0; max-width: 74px; font-size: .85rem; }
.key:active { transform: translateY(2px); }
.key.m-g, .key.m-y, .key.m-b { color: #fff; }
.key.m-g { background: #2e6b3a; } .key.m-y { background: #8a6a00; } .key.m-b { background: #5A5F78; opacity: .75; }
/* Phones: size the tiles so the board and keyboard fit on one screen below the title. */
@media (max-width: 600px) {
  .word-game { --dw: clamp(38px, min(calc((100vw - 96px) / 5), calc((100svh - 520px) / 6)), 56px); }
  .game-layout { padding-top: 12px; }
  .game-card { padding: 16px 12px; }
  .krow { gap: 4px; } .key { min-height: 50px; font-size: .95rem; }
}

.word-stats { margin-top: 18px; padding: 16px; border-radius: 18px; background: var(--surface-2); border: 2px solid var(--line); }
.word-stats h2 { margin: 0 0 10px; font-size: 1.3rem; }
.word-stats h3 { margin: 14px 0 6px; font-size: 1rem; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; text-align: center; }
.stat-row dt { font-size: .78rem; color: var(--muted); font-weight: 700; order: 2; }
.stat-row div { display: flex; flex-direction: column; }
.stat-row dd { margin: 0; font: 800 1.6rem/1.1 var(--font-display); }
.dist { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.dist li { display: flex; align-items: center; gap: 8px; }
.dist .n { width: 1ch; font-weight: 800; }
.dist .bar { width: var(--w, 8%); min-width: 2em; padding: 2px 8px; text-align: right; border-radius: 6px; background: #5A5F78; color: #fff; font-weight: 800; font-size: .9rem; }
.dist .bar.now { background: #2e6b3a; }

/* ---------- Daily Sudoku ---------- */
.sudoku-game { max-width: 480px; margin: 0 auto; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 800; font-size: .85rem; }
.pill:empty { display: none; }
.sd-grid { display: grid; grid-template-rows: repeat(9, 1fr); aspect-ratio: 1; width: 100%; border: 3px solid var(--text); border-radius: 12px; overflow: hidden; background: var(--surface); }
.sd-row { display: grid; grid-template-columns: repeat(9, 1fr); }
.sd-cell { position: relative; display: grid; place-items: center; min-width: 0; padding: 0; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); color: var(--link); font: 700 clamp(1.1rem, 5.4vw, 1.7rem)/1 var(--font-display); cursor: pointer; }
.sd-cell:nth-child(3n) { border-right: 2px solid var(--text); } .sd-cell:nth-child(9) { border-right: 0; }
.sd-row:nth-child(3n) .sd-cell { border-bottom: 2px solid var(--text); } .sd-row:nth-child(9) .sd-cell { border-bottom: 0; }
.sd-cell.given { color: var(--text); font-weight: 800; }
.sd-cell.peer { background: var(--surface-2); }
.sd-cell.same { background: rgb(77 141 255 / .28); }
.sd-cell.sel { background: rgb(77 141 255 / .5); }
.sd-cell.clash { color: var(--error); background-image: linear-gradient(rgb(255 90 70 / .18), rgb(255 90 70 / .18)); }
.sd-cell:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: 0; z-index: 1; }
.sd-notes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; padding: 2px; font: 600 clamp(.5rem, 2.1vw, .72rem)/1 var(--font-body); color: var(--muted); }
.sd-notes i { display: grid; place-items: center; font-style: normal; }
.sd-grid.solved .sd-cell { color: var(--good); }
.sd-grid.solved .sd-cell.given { color: var(--text); }
.sd-pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; margin-top: 14px; }
.sd-pad .key { max-width: none; min-height: 52px; font-size: 1.3rem; }
.sd-actions { display: flex; gap: 8px; margin-top: 10px; }
.sd-actions .btn { flex: 1; padding-left: 8px; padding-right: 8px; }
.sd-actions #sdNotes[aria-pressed="true"] { background: var(--blue); color: var(--accent-ink); border-color: var(--blue); }

/* ---------- Daily Word Search ---------- */
.ws-game { max-width: 760px; margin: 0 auto; }
.ws-theme { margin: 0 0 10px; font: 800 1.25rem/1.2 var(--font-display); }
.ws-wrap { width: 100%; }
.ws-wrap.zoomed { overflow: auto; max-height: 70svh; border-radius: 12px; border: 2px solid var(--line); }
.ws-grid { display: grid; grid-template-columns: repeat(20, 1fr); aspect-ratio: 1; width: 100%; user-select: none; -webkit-user-select: none; touch-action: none; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 4px; font: 700 clamp(.72rem, 3.4vw, 1.15rem)/1 var(--mono); text-transform: uppercase; }
.ws-grid.zoomed { width: 680px; font-size: 1.15rem; touch-action: manipulation; }
.ws-cell { display: grid; place-items: center; border-radius: 6px; cursor: pointer; aspect-ratio: 1; }
.ws-cell.f0 { background: rgb(255 122 92 / .45); } .ws-cell.f1 { background: rgb(255 204 51 / .45); } .ws-cell.f2 { background: rgb(53 220 162 / .45); }
.ws-cell.f3 { background: rgb(92 157 255 / .45); } .ws-cell.f4 { background: rgb(169 139 255 / .45); }
.ws-cell.sel { background: var(--blue); color: var(--accent-ink); }
.ws-cell.cur { outline: 3px solid var(--focus); outline-offset: -2px; }
.ws-list-title { font-size: 1.1rem; margin: 18px 0 8px; }
.ws-words { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); font: 700 .95rem/1.4 var(--font-display); }
.ws-words li.found { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }

/* ---------- Daily Crossword ---------- */
.cw-main { display: grid; gap: 18px; }
@media (min-width: 900px) { .cw-main { grid-template-columns: minmax(0, 540px) minmax(0, 1fr); align-items: start; } }
.cw-board { position: relative; }
/* Paper colours in both themes: white squares light, black squares navy. */
.cw-grid { display: grid; grid-template-rows: repeat(15, 1fr); aspect-ratio: 1; width: 100%; border: 3px solid #0A1030; background: #0A1030; gap: 1px; user-select: none; -webkit-user-select: none; }
.cw-row { display: grid; grid-template-columns: repeat(15, 1fr); gap: 1px; }
.cw-cell { position: relative; display: grid; place-items: center; background: #FAFBFF; cursor: pointer; min-width: 0; }
.cw-cell.blk { background: #0A1030; cursor: default; }
.cw-cell .n { position: absolute; left: 2px; top: 1px; font: 600 clamp(.42rem, 1.7vw, .62rem)/1 var(--font-body); color: #4A557F; }
.cw-cell .l { font: 700 clamp(.85rem, 4vw, 1.35rem)/1 var(--font-display); text-transform: uppercase; color: #0A1030; margin-top: 3px; }
.cw-cell.inword { background: #D4E3FF; }
.cw-cell.sel { background: var(--sun); }
.cw-cell.sel .l, .cw-cell.sel .n { color: var(--tile-ink); }
.cw-cell.bad .l { color: #B3261E; }
.cw-cell.bad::after { content: ""; position: absolute; inset: auto 15% 8% 15%; height: 2px; background: #B3261E; }
.cw-cell.rev::before { content: ""; position: absolute; right: 0; top: 0; border: 5px solid transparent; border-top-color: var(--coral); border-right-color: var(--coral); }
.cw-grid.solved .cw-cell:not(.blk) .l { color: #1E7A45; }
.cw-grid.solved .cw-cell.sel .l { color: var(--tile-ink); }
.cw-bar { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 8px; border-radius: 14px; background: var(--surface-2); border: 2px solid var(--line); min-height: 64px; }
.cw-bar p { flex: 1; margin: 0; font-size: 1rem; line-height: 1.35; }
.cw-step { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--outline); background: transparent; color: var(--text); font: 800 1.4rem/1 var(--font-display); cursor: pointer; }
/* The input that receives typing (and opens the phone keyboard) sits under the grid, invisible. */
.cw-input { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; }
.cw-lists { display: grid; gap: 14px; }
@media (min-width: 600px) { .cw-lists { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .cw-lists { max-height: 600px; overflow: auto; } }
.cw-lists h2 { font-size: 1.05rem; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: var(--font-body); }
.cw-clues { list-style: none; margin: 0; padding: 0; font-size: .95rem; }
.cw-clues li { display: flex; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; border-left: 4px solid transparent; }
.cw-clues li b { min-width: 2ch; text-align: right; }
.cw-clues li.on { background: rgb(77 141 255 / .28); border-left-color: var(--blue); }
.cw-clues li.cross { background: var(--surface-2); }
.cw-menu { position: relative; }
.cw-menu summary { list-style: none; }
.cw-menu summary::-webkit-details-marker { display: none; }
.cw-menu > div { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; min-width: 140px; padding: 6px; border-radius: 14px; background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow); }
.cw-menu > div button { min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; font: 700 .95rem var(--font-body); cursor: pointer; }
.cw-menu > div button:hover { background: var(--surface-2); }
/* Phones: the clue bar sticks to the bottom of the screen, just above the keyboard. */
@media (max-width: 899px) {
  .cw-bar { position: sticky; bottom: 0; z-index: 10; box-shadow: 0 -8px 16px -8px rgb(0 0 0 / .35); }
}

/* ---------- share buttons ---------- */
.share-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- hint pages ---------- */
.hints-game { max-width: 620px; }
.spoiler-warning { padding: 12px 14px; border-radius: 14px; border: 2px solid var(--sun); background: var(--surface-2); }
.hint-list { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 12px; }
.hint-list .hint { display: grid; gap: 6px; justify-items: start; }
.hint-text { margin: 0; font-weight: 700; font-size: 1.1rem; }

/* ---------- Letterpile ---------- */
.lp-game { max-width: 520px; margin: 0 auto; }
.lp-wrap { width: min(100%, 440px); margin: 0 auto; }
.lp-board { --n: 5; position: relative; width: 100%; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 20px; background: var(--surface-2); border: 2px solid var(--line); }
.lp-tile { --pad: 4px; position: absolute; left: 0; top: 0; width: calc(100% / var(--n)); height: calc(100% / var(--n)); --ts: 100%; border: 0; padding: 0; cursor: pointer;
  font-size: clamp(1.3rem, 7vw, 2.2rem); background-clip: content-box; padding: var(--pad); background: transparent;
  transform: translate(calc(var(--c) * 100%), calc((var(--n) - 1 - var(--r)) * 100%)); transition: transform .38s cubic-bezier(.3, 1.35, .55, 1), opacity .2s ease; box-shadow: none; }
.lp-tile::before { content: ""; position: absolute; inset: var(--pad); border-radius: 12px; background: var(--wood); box-shadow: inset 0 -4px 0 rgb(0 0 0 / .16), inset 0 2px 0 rgb(255 255 255 / .5), 0 3px 0 rgb(0 0 0 / .22); z-index: -1; transition: background .12s ease; }
.lp-tile { z-index: 0; isolation: isolate; color: var(--tile-ink); font-weight: 800; font-family: var(--font-display); text-transform: uppercase; display: grid; place-items: center; }
.lp-tile sup { position: absolute; right: calc(var(--pad) + 7%); bottom: calc(var(--pad) + 6%); font-size: .42em; }
.lp-tile.on::before { background: var(--sun); box-shadow: inset 0 0 0 3px var(--tile-ink), 0 3px 0 rgb(0 0 0 / .22); }
.lp-tile.hint::before { background: var(--mint); animation: lp-pulse 1s ease-in-out infinite alternate; }
.lp-tile.gone { opacity: 0; transform: translate(calc(var(--c) * 100%), calc((var(--n) - 1 - var(--r)) * 100%)) scale(.4); }
.lp-tile.dead { color: var(--muted); }
.lp-tile.dead::before { opacity: .4; box-shadow: none; }
.lp-note { margin: 8px 0 0; text-align: center; font-weight: 700; color: var(--muted); }
.lp-tile:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; border-radius: 14px; }
@keyframes lp-pulse { to { transform: scale(1.06); } }
.lp-board.shake { animation: shake .35s ease; }
.lp-current { min-height: 48px; display: grid; place-items: center; margin-top: 10px; }
.lp-word { font: 800 1.8rem/1 var(--font-display); letter-spacing: .12em; }
.lp-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.lp-played { list-style: decimal inside; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-weight: 700; }
.lp-timer-toggle { min-height: 44px; }
.lp-n { width: auto; min-width: 7.5em; font-size: .85rem; }
.lp-how { max-width: 460px; border: 2px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); padding: 22px; }
.lp-how::backdrop { background: rgb(10 16 48 / .6); }
.lp-how h2 { margin: 0 0 12px; }
.lp-how-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 14px; }
.lp-how-steps li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; }
.lp-demo { display: flex; gap: 3px; }
.lp-demo i { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--wood); color: var(--tile-ink); font: 800 1rem var(--font-display); font-style: normal; box-shadow: 0 2px 0 rgb(0 0 0 / .2); }
.lp-demo1 i { animation: lp-pick 2.4s infinite; } .lp-demo1 i:nth-child(2) { animation-delay: .3s; } .lp-demo1 i:nth-child(3) { animation-delay: .6s; }
.lp-demo2 i { animation: lp-drop 2.4s infinite; }
.lp-demo3 i { background: var(--mint); }
@keyframes lp-pick { 0%, 20% { background: var(--wood); } 30%, 80% { background: var(--sun); } 100% { background: var(--wood); } }
@keyframes lp-drop { 0%, 40% { transform: none; opacity: 1; } 55% { transform: scale(.4); opacity: 0; } 70% { transform: translateY(-20px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.wotd-word { font: 800 clamp(2.2rem, 9vw, 3.4rem)/1.1 var(--font-display); letter-spacing: .08em; margin: 6px 0 14px; overflow-wrap: anywhere; }
.wotd-notes { display: grid; gap: 4px 0; margin: 0 0 14px; }
.wotd-notes dt { font-size: .8rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-top: 10px; }
.wotd-notes dd { margin: 0; }
.wotd-archive { padding-left: 1.2em; }
.all-games { border: 2px solid var(--line); border-radius: 16px; padding: 12px 16px; margin: 12px 0; }
.all-games p { margin: 4px 0; }
.meter { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; width: var(--w, 0%); background: var(--mint); transition: width .3s; }
