/* Word Search Maker */
.ws-seg { margin-bottom: 0; }
.ws-seg .seg-btn { flex: 1 1 0; }

@media (max-width: 520px) { body .tool-card.ws-card { padding: 14px 10px; } }

.ws-bar {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}
.ws-status {
    flex: 1 1 auto; margin: 0; min-height: 2.8em; padding: 8px 12px;
    background: var(--color-yolk-soft); border-radius: var(--radius-md); font-weight: 600; line-height: 1.35;
    display: flex; align-items: center;
}
.ws-status:empty { display: none; }
.ws-time {
    flex: 0 0 auto; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
    font-variant-numeric: tabular-nums; padding: 6px 12px; border: var(--line) solid var(--color-ink);
    border-radius: 999px; background: var(--color-warm-white); color: var(--color-ink);
}

/* A wide board scrolls inside its card instead of widening the page. */
.ws-board-wrap {
    position: relative; overflow-x: auto; padding: 4px 4px 8px; margin-bottom: var(--space-md);
    -webkit-overflow-scrolling: touch; text-align: center;
}
.ws-board {
    --cell: 32px;
    position: relative; display: inline-block; vertical-align: top;
    background: #fff; border: var(--line) solid var(--color-ink); border-radius: var(--radius-md);
    box-shadow: var(--pop-sm);
    touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
    cursor: pointer;
}
.ws-cells {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: repeat(var(--n), var(--cell));
}
.ws-row { display: contents; }
.ws-cell {
    width: var(--cell); height: var(--cell);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-family); font-weight: 800; color: #1d1a16;
    font-size: max(min(12px, calc(var(--cell) * .9)), calc(var(--cell) * .6)); line-height: 1;
    border-radius: 50%; outline: none;
}
.ws-cell:focus-visible { box-shadow: inset 0 0 0 3px #221E1A; }
.ws-cell.start { background: rgba(233, 178, 60, .55); box-shadow: inset 0 0 0 2px #221E1A; }

.ws-marks { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.ws-mark { stroke-width: .78; stroke-linecap: round; fill: none; opacity: .8; }
.ws-mark--shown { stroke: #DDD6CA; opacity: 1; stroke-dasharray: .08 .14; stroke-width: .7; }
.ws-mark--sel { stroke: #E9B23C; opacity: .6; }
.ws-mark--sel.bad { stroke: #E8593F; opacity: .45; }

.ws-done:empty { display: none; }
.ws-list-h { font-size: 1.1rem; margin: 0 0 6px; color: var(--color-ink); }
.ws-list {
    list-style: none; margin: 0 0 var(--space-md); padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 10px;
}
.ws-list li { display: flex; align-items: center; gap: 8px; min-height: 32px; font-weight: 700; min-width: 0; }
.ws-word { overflow-wrap: anywhere; }
.ws-dot {
    flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--color-warm-gray); background: var(--hl, transparent);
}
.ws-list li.found .ws-dot { border-color: var(--color-ink); }
.ws-list li.found .ws-word { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--color-muted-brown); }
.ws-list li.shown .ws-word { color: var(--color-muted-brown); font-style: italic; }
.ws-actions { margin-bottom: var(--space-sm); }
.ws-share { margin-top: var(--space-md); }
.ws-print-opts { margin-top: var(--space-md); display: flex; flex-wrap: wrap; gap: 0 var(--space-lg); align-items: flex-end; }
.ws-copies { margin: 0; width: 140px; }

.ws-shared .tool-grid { grid-template-columns: minmax(0, 1fr); }

/* the celebration: a little hop and some falling eggs */
.ws-board.cheer { animation: ws-hop .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes ws-hop { 0% { transform: scale(1); } 40% { transform: scale(1.03) rotate(-.6deg); } 100% { transform: scale(1); } }
.ws-confetti {
    position: absolute; top: 0; font-size: 22px; pointer-events: none; z-index: 3;
    animation: ws-fall 1.5s ease-in forwards;
}
@keyframes ws-fall { from { transform: translateY(-10px) rotate(0); opacity: 1; } to { transform: translateY(260px) rotate(200deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .ws-board.cheer, .ws-confetti { animation: none; }
    .ws-confetti { display: none; }
}

/* ---- Print: the sheets only ---- */
@media print {
    #ws-head, .ws-card { display: none !important; }
    .ws-sheet { break-after: page; }
    .ws-sheet:last-child { break-after: auto; }
    .ws-sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12mm; margin-bottom: 2mm; }
    .ws-sheet-head h2 { margin: 0; font-size: 20pt; }
    .ws-sheet-name { margin: 0; font-size: 12pt; white-space: nowrap; }
    .ws-sheet-name span { display: inline-block; width: 55mm; border-bottom: 1px solid #000; }
    .ws-sheet-how { margin: 0 0 4mm; font-size: 11pt; color: #333; }
    .ws-sheet-grid { position: relative; width: max-content; margin: 0 auto 6mm; border: 1.5px solid #000; }
    .ws-sheet-cells { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(var(--n), var(--pc)); }
    .ws-sheet-cells span {
        width: var(--pc); height: var(--pc); display: flex; align-items: center; justify-content: center;
        font-family: var(--font-family); font-weight: 800; font-size: calc(var(--pc) * .6); color: #000;
    }
    .ws-sheet-cells span.off { color: #aaa; font-weight: 600; }
    .ws-sheet-marks { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
    /* hand-circled answers: every black capsule first, then every white inside, so crossings merge */
    .ws-sheet-marks line { stroke-linecap: round; fill: none; }
    .ws-sheet-marks .o { stroke: #000; stroke-width: .8; }
    .ws-sheet-marks .i { stroke: #fff; stroke-width: .66; }
    .ws-sheet-list { list-style: none; padding: 0; margin: 0; columns: 3; column-gap: 8mm; font-size: 12pt; font-weight: 700; }
    .ws-sheet-list li { padding: 1mm 0; break-inside: avoid; }
    .ws-sheet-list--dense { columns: 4; column-gap: 6mm; font-size: 10pt; }
    .ws-sheet-list--dense li { padding: .5mm 0; }
    .ws-sheet-list li::before { content: '☐ '; font-weight: 400; }
    .ws-sheet-count { font-size: 13pt; font-weight: 700; }
}
