.puzzle-builder { display: grid; gap: 14px; padding: 16px 0; min-width: 0; }
.puzzle-builder h3, .puzzle-dialog h2 { margin: 0; font-size: 18px; }
.puzzle-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.puzzle-toolbar h3 { margin-right: auto; }
.puzzle-toolbar label { display: flex; gap: 8px; align-items: center; }
.puzzle-toolbar input[type=number], .puzzle-ai-count input { width: 72px; }
.puzzle-instructions, .puzzle-ai-output { display: grid; gap: 6px; }
.puzzle-instructions textarea, .puzzle-ai-output textarea { width: 100%; box-sizing: border-box; }
.puzzle-entries { display: grid; gap: 8px; }
.puzzle-entry { display: grid; grid-template-columns: 26px minmax(100px, 1fr) minmax(130px, 2fr) 36px; align-items: center; gap: 8px; }
.puzzle-entry.word-only { grid-template-columns: 26px minmax(100px, 1fr) 36px; }
.puzzle-entry input { min-width: 0; width: 100%; box-sizing: border-box; }
.puzzle-builder input, .puzzle-builder select, .puzzle-builder textarea,
.puzzle-dialog input:not(.puzzle-letter), .puzzle-dialog textarea {
  color: inherit; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.2);
  border-radius: 5px; padding: 8px 10px; font: inherit; box-sizing: border-box;
}
.puzzle-builder select option { color: #eee; background: #20242a; }
.puzzle-word-list-toggle input[type=checkbox] { width: 18px; height: 18px; margin: 0; padding: 0; flex: 0 0 18px; accent-color: #319979; }
.puzzle-remove { width: 36px; height: 36px; padding: 0; font-size: 22px; }
.puzzle-status { color: var(--panel-header-text, #f6b760); font-size: 14px; min-height: 20px; overflow-wrap: anywhere; }
.puzzle-play { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 22px; min-width: 0; max-width: 100%; }
.puzzle-grid-scroll { max-width: 100%; min-width: 0; overflow: auto; padding: 2px; }
.puzzle-grid { display: grid; grid-template-columns: repeat(var(--puzzle-cols), minmax(0,1fr)); max-width: 100%; border: 1px solid #555; background: #292929; touch-action: none; user-select: none; }
.puzzle-cell { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; box-sizing: border-box; background: #fff; border: 1px solid #757575; color: #161616; }
.puzzle-cell.blocked { background: #292929; border-color: #292929; }
.puzzle-cell .puzzle-letter { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 5px 0 0; text-align: center; border: 0; border-radius: 0; background: transparent; color: #161616; font: 600 19px/1 system-ui, sans-serif; letter-spacing: 0; box-sizing: border-box; cursor: pointer; box-shadow: none; opacity: 1; }
.puzzle-cell-number { position: absolute; top: 0; left: 2px; font: 9px/1.1 system-ui, sans-serif; color: #222; pointer-events: none; }
.puzzle-cell.active-word { background: #d6effb; }
.puzzle-cell:focus-within { box-shadow: inset 0 0 0 3px #1373b4; z-index: 1; }
.puzzle-cell.pending { background: #ffe390; }
.puzzle-cell.found { background: #a7e1c5; }
.puzzle-clues { flex: 1 1 200px; min-width: 0; max-width: 500px; display: grid; gap: 6px; }
.puzzle-clues h3 { margin: 8px 0 0; font-size: 16px; }
.puzzle-clue { text-align: left; color: inherit; background: transparent; border: 1px solid transparent; padding: 7px 9px; border-radius: 4px; font: inherit; overflow-wrap: anywhere; cursor: pointer; }
.puzzle-clue.active { background: rgba(34,170,225,.14); border-color: #329ad0; }
.puzzle-word { font-size: 15px; overflow-wrap: anywhere; }
.puzzle-word.found { color: #76d9aa; text-decoration: line-through; }
.puzzle-dialog { width: min(1050px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-sizing: border-box; overflow: auto; border: 1px solid #666; border-radius: 8px; padding: 18px; background: var(--panel-bg, #191d23); color: var(--text, #eee); }
.puzzle-dialog::backdrop { background: rgba(0,0,0,.65); }
.puzzle-dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.puzzle-dialog-body { display: grid; gap: 14px; min-width: 0; }
.puzzle-ai-count { display: flex; align-items: center; gap: 8px; }
@media (max-width: 550px) {
  .puzzle-cell .puzzle-letter { font-size: 14px; padding-top: 4px; }
  .puzzle-cell-number { font-size: 8px; }
  .puzzle-entry { grid-template-columns: 22px minmax(0, 1fr) 36px; }
  .puzzle-entry:not(.word-only) input:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  .puzzle-entry:not(.word-only) .puzzle-remove { grid-column: 3; grid-row: 1 / 3; }
  .puzzle-dialog { padding: 10px; width: calc(100vw - 16px); }
  .puzzle-dialog h2 { font-size: 17px; }
}
