/* /play word search game. Mobile first, big letters, no italics anywhere. */
.pl-hero { background: var(--slate); color: #fff; text-align: center; padding: 32px 20px 26px; }
.pl-hero h1 { font-family: 'Playfair Display', serif; font-size: 2rem; line-height: 1.2; margin: 0 0 8px; font-style: normal; }
.pl-hero-by { margin: 0; font-size: 1.15rem; color: #F2E6CC; }

.pl-wrap { max-width: 1040px; margin: 0 auto; padding: 12px 6px 48px; font-size: 1.15rem; line-height: 1.55; font-style: normal; }
.pl-wrap *, .pl-wrap *::before, .pl-wrap *::after { font-style: normal; }
.pl-wrap h1 { font-family: 'Playfair Display', serif; font-size: 1.55rem; line-height: 1.25; margin: 4px 0 6px; color: var(--slate-dark); }
.pl-wrap h2 { font-family: 'Playfair Display', serif; font-size: 1.35rem; margin: 0 0 8px; color: var(--slate-dark); }
.pl-intro { font-size: 1.25rem; }
.pl-levels { color: #333; }
.pl-more { margin-top: 28px; }
.pl-crumbs { margin: 0 0 4px; }
.pl-crumbs a { display: inline-block; padding: 10px 4px; min-height: 44px; font-weight: 600; }
.pl-meta { margin: 0 0 10px; color: #333; font-size: 1.05rem; }
.pl-levelnote { display: block; color: #444; font-size: 1rem; }
.pl-noscript { background: #fff3cd; border: 2px solid #8a6d00; padding: 12px; border-radius: 6px; }

/* Buttons (all at least 48px tall) */
.pl-btn { display: inline-flex; align-items: center; justify-content: center; text-align: center; background: var(--slate); color: #fff !important; text-decoration: none; font: 600 1.1rem/1.2 Arial, Helvetica, sans-serif; padding: 12px 20px; min-height: 48px; min-width: 48px; border: 2px solid var(--slate); border-radius: 8px; cursor: pointer; }
.pl-btn:hover { background: var(--slate-dark); border-color: var(--slate-dark); }
.pl-btn-alt { background: #fff; color: var(--slate-dark) !important; }
.pl-btn-alt:hover { background: var(--parchment); border-color: var(--slate-dark); }
.pl-btn[hidden] { display: none; }
.pl-btn[disabled] { opacity: .55; cursor: default; }
.pl-controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }

/* Difficulty labels: always words, never colour alone */
.pl-diff { display: inline-block; font: 700 .85rem/1 Arial, Helvetica, sans-serif; letter-spacing: .03em; text-transform: uppercase; padding: 5px 9px; border-radius: 999px; border: 2px solid; background: #fff; vertical-align: middle; }
.pl-diff-easy { color: #1d5e2b; border-color: #1d5e2b; }
.pl-diff-medium { color: #7a4a00; border-color: #7a4a00; }
.pl-diff-hard { color: #8b1d1d; border-color: #8b1d1d; }

/* ---------- listing ---------- */
.pl-book { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin: 14px 0; }
.pl-book > summary { cursor: pointer; padding: 14px 16px; min-height: 56px; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.pl-book > summary::-webkit-details-marker { display: none; }
.pl-book > summary::before { content: "+"; font: 700 1.6rem/1 Arial, Helvetica, sans-serif; color: var(--slate); width: 1.2em; }
.pl-book[open] > summary::before { content: "\2212"; }
.pl-book-title { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 1.3rem; color: var(--slate-dark); flex: 1 1 14rem; }
.pl-book-count, .pl-book-done { font-size: 1rem; color: #444; }
.pl-puzzles { list-style: none; margin: 0; padding: 0 10px 12px; display: grid; gap: 8px; grid-template-columns: 1fr; }
.pl-puzzle { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; background: var(--bg); border: 2px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; }
.pl-puzzle:hover { border-color: var(--slate); background: #fff; }
.pl-num { flex: 0 0 auto; min-width: 2.4em; text-align: center; font: 700 1.1rem/1 Arial, Helvetica, sans-serif; background: var(--slate); color: #fff; border-radius: 999px; padding: 8px 6px; }
.pl-name { flex: 1 1 auto; font-weight: 600; line-height: 1.25; }
.pl-state { flex: 0 0 auto; font: 700 .9rem/1.1 Arial, Helvetica, sans-serif; color: #1d5e2b; }
.pl-puzzle .pl-diff { flex: 0 0 auto; }

/* ---------- game ---------- */
.pl-layout { display: block; }
.pl-progress { font: 700 1.25rem/1.3 Arial, Helvetica, sans-serif; margin: 6px 2px; color: var(--slate-dark); }

/* The gridwrap is a square that fills the width; the pills sit behind the letters. */
.pl-gridwrap { position: relative; width: 100%; aspect-ratio: 1 / 1; max-width: 680px; margin: 0 auto; background: #fff; border: 2px solid var(--slate); border-radius: 8px; overflow: hidden; container-type: inline-size; }
.pl-pills { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.pl-grid { position: absolute; inset: 0; z-index: 1; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; cursor: crosshair; }
.pl-cell { display: flex; align-items: center; justify-content: center; font-family: Arial, Helvetica, "Liberation Sans", sans-serif; font-weight: 800; color: #111; line-height: 1; font-size: 4.4vw; font-size: calc(100cqw / var(--n) * .8); }
.pl-cell.pl-hint { box-shadow: inset 0 0 0 3px #b3261e; background: #fde7e5; border-radius: 6px; }
.pl-grid:focus .pl-cell.pl-cur { box-shadow: inset 0 0 0 3px var(--slate-dark); border-radius: 6px; }
.pl-grid:focus { outline: none; }

.pl-pill { position: absolute; border-radius: 999px; transform-origin: 50% 50%; border: 2px solid; box-sizing: border-box; }
.pl-pill-sel { background: rgba(201,169,110,.65); border-color: #7a5b1c; }
.pl-pill-bad { background: rgba(196,68,68,.35); border-color: #8b1d1d; border-style: dashed; }
.pl-pill-found.c0 { background: rgba(120,190,255,.55); border-color: #1d5a99; }
.pl-pill-found.c1 { background: rgba(130,220,140,.55); border-color: #1d6b2b; }
.pl-pill-found.c2 { background: rgba(255,190,110,.6); border-color: #9a5a00; }
.pl-pill-found.c3 { background: rgba(230,160,230,.55); border-color: #7a2a7a; }
.pl-pill-found.c4 { background: rgba(150,225,215,.6); border-color: #12685e; }
.pl-pill-found.c5 { background: rgba(250,225,100,.65); border-color: #7a6700; }
.pl-pill-shown { background: rgba(160,160,160,.35); border-color: #555; border-style: dotted; }

.pl-help { margin: 8px 2px 0; color: #333; font-size: 1.05rem; }
.pl-message { min-height: 1.6em; margin: 6px 2px 0; font: 700 1.1rem/1.4 Arial, Helvetica, sans-serif; color: var(--slate-dark); }
.pl-shake { animation: pl-shake .35s; }
@keyframes pl-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.pl-hint-pulse { animation: pl-pulse .7s ease-in-out 3; }
@keyframes pl-pulse { 0%,100% { background: #fde7e5; } 50% { background: #f6a8a1; } }

.pl-confirm { background: #fff; border: 3px solid var(--slate); border-radius: 8px; padding: 6px 14px; margin: 10px 0; }
.pl-confirm[hidden], .pl-done[hidden] { display: none; }

.pl-wordbox { margin-top: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px 16px; }
.pl-words { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 2px 12px; }
.pl-word { display: flex; align-items: center; gap: 8px; min-height: 44px; font: 700 1.25rem/1.2 Arial, Helvetica, sans-serif; letter-spacing: .02em; color: #111; }
.pl-mark { flex: 0 0 1.4em; text-align: center; }
.pl-mark::before { content: "\25CB"; color: #444; }
.pl-word.pl-found { color: #4a4a4a; }
.pl-word.pl-found .pl-wtext { text-decoration: line-through; text-decoration-thickness: 3px; }
.pl-word.pl-found .pl-mark::before { content: "\2713"; color: #1d5e2b; font-weight: 800; }
.pl-word.pl-shown .pl-mark::before { content: "\25CF"; color: #555; }
.pl-word.pl-shown .pl-wtext::after { content: " (shown)"; font-weight: 400; font-size: .85em; }

.pl-done { margin-top: 20px; background: #fff; border: 3px solid #1d5e2b; border-radius: 8px; padding: 14px 16px 10px; }
.pl-done h2 { color: #1d5e2b; }
.pl-done .pl-more { margin: 8px 0 6px; }

.pl-error { text-align: center; padding-top: 40px; }

@media (max-width: 599px) {
  /* Let the board use the whole screen width so 16x16 puzzles keep big letters. */
  .pl-gridwrap { margin-left: -6px; margin-right: -6px; width: calc(100% + 12px); border-left-width: 0; border-right-width: 0; border-radius: 0; }
}
@media (min-width: 600px) {
  .pl-hero h1 { font-size: 2.5rem; }
  .pl-wrap { padding: 24px 18px 56px; }
  .pl-wrap h1 { font-size: 1.9rem; }
  .pl-puzzles { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .pl-layout { display: grid; grid-template-columns: minmax(0, 620px) minmax(0, 1fr); gap: 28px; align-items: start; }
  .pl-wordbox { margin-top: 38px; }
  .pl-puzzles { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .pl-shake, .pl-hint-pulse { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ---------- toggle button + hidden-by-default full-screen pieces ---------- */
.pl-toprow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.pl-fs-toggle { min-height: 48px; padding: 10px 18px; }
.pl-fs-toggle::before { content: "\2922"; font-size: 1.3em; margin-right: 8px; }
.pl-fsbar, .pl-fs-only { display: none; }

/* ---------- FULL-SCREEN PLAY MODE (html.pl-fs-on) ----------
   Only the board, the word list and a thin control strip are shown. JS sets
   --fs-s (board size), --fs-wf (word font size) and --fs-colw (column width). */
html.pl-fs-on, html.pl-fs-on body { overflow: hidden; overscroll-behavior: none; }
html.pl-fs-on nav, html.pl-fs-on footer, html.pl-fs-on .skip-link { display: none !important; }
html.pl-fs-on .pl-game {
  position: fixed; inset: 0; z-index: 1000; width: auto; max-width: none; margin: 0;
  height: 100vh; height: 100dvh;
  padding: calc(4px + env(safe-area-inset-top, 0px)) calc(4px + env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) calc(4px + env(safe-area-inset-left, 0px));
  background: var(--bg); overflow: hidden; font-size: 16px; line-height: 1.2;
  display: grid; gap: 6px; align-content: start; justify-content: stretch;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "bar" "board" "words";
  touch-action: none;
}
html.pl-fs-on .pl-game.pl-fs-land {
  grid-template-columns: var(--fs-s, 60vh) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "board bar" "board words";
}
html.pl-fs-on .pl-layout, html.pl-fs-on .pl-board { display: contents; }
html.pl-fs-on .pl-toprow, html.pl-fs-on .pl-game > h1, html.pl-fs-on .pl-meta, html.pl-fs-on noscript,
html.pl-fs-on .pl-progress, html.pl-fs-on .pl-help, html.pl-fs-on .pl-message,
html.pl-fs-on .pl-board > .pl-controls, html.pl-fs-on .pl-confirm { display: none !important; }
html.pl-fs-on .pl-wordbox h2 { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }

html.pl-fs-on .pl-fsbar { grid-area: bar; display: flex; align-items: center; gap: 6px; min-height: 44px; }
.pl-fsb { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 6px 12px; font: 700 1rem/1.1 Arial, Helvetica, sans-serif; color: var(--slate-dark) !important; background: #fff; border: 2px solid var(--slate); border-radius: 8px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.pl-fsb:hover { background: var(--parchment); }
.pl-fsb-exit { background: var(--slate); color: #fff !important; margin-right: auto; }
.pl-fsb-exit:hover { background: var(--slate-dark); }
.pl-fs-long { display: none; }
.pl-fs-short { display: inline; }
.pl-fsb-exit > span:first-child { font-size: 1.4rem; line-height: 1; margin-right: 6px; }
.pl-fscount { font: 700 1.1rem/1 Arial, Helvetica, sans-serif; color: var(--slate-dark); padding: 0 6px; white-space: nowrap; }
@media (min-width: 480px) { .pl-fs-long { display: inline; } .pl-fs-short { display: none; } }

html.pl-fs-on .pl-gridwrap {
  grid-area: board; justify-self: center; align-self: start;
  width: var(--fs-s, min(94vw, 50dvh)); height: var(--fs-s, min(94vw, 50dvh)); max-width: none;
  margin: 0; border: 2px solid var(--slate); border-radius: 6px; aspect-ratio: auto;
}
html.pl-fs-on .pl-wordbox { grid-area: words; align-self: start; margin: 0; padding: 4px 8px 5px; border-radius: 6px; }
html.pl-fs-on .pl-words { grid-template-columns: repeat(auto-fill, minmax(var(--fs-colw, 8.4em), 1fr)); gap: 0 8px; }
html.pl-fs-on .pl-word { min-height: 0; padding: 1px 0; font-size: var(--fs-wf, 16px); line-height: 1.2; gap: 4px; white-space: nowrap; }
html.pl-fs-on .pl-word.pl-found .pl-wtext { text-decoration-thickness: 2px; }
html.pl-fs-on .pl-mark { flex: 0 0 1.1em; }

/* completion card: compact, centred over the board */
html.pl-fs-on .pl-done {
  position: fixed; z-index: 1100; left: 10px; right: 10px; top: 50%; transform: translateY(-50%);
  max-width: 460px; margin: 0 auto; padding: 10px 14px 8px; max-height: 92vh; max-height: 92dvh; overflow: auto;
  box-shadow: 0 6px 30px rgba(0,0,0,.35); touch-action: auto;
}
html.pl-fs-on .pl-done[hidden] { display: none; }
html.pl-fs-on .pl-done h2 { font-size: 1.25rem; margin: 0 0 4px; }
html.pl-fs-on .pl-done p { margin: 0 0 6px; font-size: 1rem; }
html.pl-fs-on .pl-done .pl-controls { margin: 6px 0; gap: 8px; }
html.pl-fs-on .pl-done .pl-btn { font-size: 1rem; padding: 8px 14px; min-height: 46px; flex: 1 1 auto; }
html.pl-fs-on .pl-done .pl-more { font-size: .95rem; margin: 4px 0; }
html.pl-fs-on .pl-fs-only { display: inline-flex; }
html.pl-fs-on .pl-nofs { display: none; }
