/* Word Search & Crossword Maker */
.pm-sheet { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.pm-title { text-align: center; margin-bottom: .25rem; }
.pm-help { text-align: center; min-height: 1.5em; font-weight: 600; }
.pm-disc { display: none; }

/* Word search */
.pm-search {
    --n: 12; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px;
    max-width: min(100%, 34rem); margin: 0 auto 1rem; user-select: none;
}
.pm-cell {
    aspect-ratio: 1; padding: 0; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
    font: inherit; font-weight: 800; font-size: clamp(.8rem, 3.2vw, 1.25rem); color: var(--ink);
}
.pm-cell:hover { background: var(--accent-soft); }
.pm-cell.is-start { background: var(--accent); color: #fff; }
.pm-cell.is-found { background: #dcfce7; color: #15803d; }
.pm-cell.is-key { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.pm-words { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .25rem 1rem; max-width: 40rem; margin-inline: auto; }
.pm-words li { font-weight: 700; }
.pm-words li.is-found { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: #15803d; text-decoration-thickness: 3px; }

/* Crossword */
.pm-cross { --cols: 10; --rows: 10; display: grid; grid-template-columns: repeat(var(--cols), 1fr); max-width: min(100%, calc(var(--cols) * 2.6rem)); margin: 0 auto 1rem; }
.pm-x { position: relative; aspect-ratio: 1; border: 1px solid var(--ink); margin: 0 -1px -1px 0; background: var(--surface); }
.pm-x.is-block { border-color: transparent; background: transparent; }
.pm-n { position: absolute; top: 1px; left: 2px; font-size: clamp(.45rem, 1.5vw, .65rem); font-weight: 700; line-height: 1; pointer-events: none; }
.pm-x input {
    width: 100%; height: 100%; border: 0; padding: 0; text-align: center; background: transparent;
    font: inherit; font-weight: 800; font-size: clamp(.8rem, 3vw, 1.2rem); text-transform: uppercase; color: var(--ink);
}
.pm-x input:focus { outline: 3px solid var(--accent); outline-offset: -3px; background: var(--accent-soft); }
.pm-x input.is-wrong { color: #b91c1c; background: #fee2e2; }
.pm-a { display: grid; place-items: center; height: 100%; font-weight: 800; }
.pm-clues { display: grid; gap: 1rem; }
@media (min-width: 640px) { .pm-clues { grid-template-columns: 1fr 1fr; } }
.pm-clues h3 { margin: 0 0 .4rem; }
.pm-clues ol { margin: 0; padding-left: 1.75rem; }
.pm-clues li { margin-bottom: .3rem; }
.pm-len { color: var(--ink-soft); font-size: .9em; }
.pm-keyopt { display: inline-flex; gap: .5rem; align-items: center; font-weight: 600; cursor: pointer; }
.pm-keyopt input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.pm-new svg, .pm-print svg { width: 1.1rem; height: 1.1rem; }

@media print {
    body.pm-printing .site-header, body.pm-printing .site-footer, body.pm-printing .page-head,
    body.pm-printing .g-footnote, body.pm-printing .no-print { display: none !important; }
    body.pm-printing .section { padding: 0; }
    body.pm-printing .pm-sheet { border: 0; box-shadow: none; padding: 0; position: relative; min-height: 250mm; }
    body.pm-printing .pm-key:not([hidden]) { display: block; break-before: page; }
    body.pm-printing .pm-title { font-size: 18pt; margin-bottom: 5mm; }
    body.pm-printing .pm-disc { display: block; position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 7pt; color: #444; margin: 0; }
    body.pm-printing .pm-search { max-width: 150mm; gap: 0; }
    body.pm-printing .pm-cell { font-size: 14pt; background: none !important; color: #000 !important; }
    body.pm-printing .pm-body .pm-cell.is-key { box-shadow: none; }
    body.pm-printing .pm-key .pm-cell.is-key { box-shadow: none; background: #ddd !important; border-radius: 0; }
    body.pm-printing .pm-words li { text-decoration: none; color: #000; }
    body.pm-printing .pm-cross { max-width: min(170mm, calc(var(--cols) * 11mm), calc(var(--cols) * 135mm / var(--rows))); }
    body.pm-printing .pm-key .pm-cross { max-width: min(180mm, calc(var(--cols) * 12mm), calc(var(--cols) * 210mm / var(--rows))); }
    body.pm-printing .pm-x input { color: transparent; }
    body.pm-printing .pm-x.is-block { background: transparent; }
    body.pm-printing .pm-clues { grid-template-columns: 1fr 1fr; font-size: 10pt; }
}
