/* Force single-column layout (maincss uses sidebar grid otherwise) */
.crossword-page.grid {
  grid-template-columns: 1fr;
  grid-template-areas: "topnav" "main" "footer";
}
.crossword-page .topnav { grid-column: 1; }
.crossword-page main { grid-row: 2; grid-column: 1; }
.crossword-page .footer { grid-column: 1; }

/* --- Setup Card (matches winner_setup_card pattern) --- */
.crossword_cardbox {
  text-align: center;
  margin: 20px auto;
  width: 100%;
  max-width: 800px;
}

.crossword_setup_card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 30px 32px;
  margin: 20px auto;
  max-width: 600px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  text-align: left;
}
.crossword_setup_card h2 {
  margin-bottom: 4px;
  color: #2c3e50;
  letter-spacing: -0.5px;
  font-size: 1.4rem;
}
.crossword_setup_card > p {
  margin-bottom: 20px;
  color: #777;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* --- Form Fields (match site field pattern) --- */
.cw-field { margin-bottom: 18px; }
.cw-field label {
  display: block;
  margin-bottom: 5px;
  color: #444;
  font-size: 0.88rem;
  font-weight: 600;
}
.cw-field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cw-field input[type="text"]:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}
.cw-field .hint {
  font-size: 0.78rem;
  color: #999;
  margin-top: 5px;
}

/* --- Input Mode Tabs --- */
.cw-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  overflow: hidden;
  width: fit-content;
}
.cw-tab {
  padding: 7px 18px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #f5f7fa;
  color: #555;
  transition: background 0.15s, color 0.15s;
  border-radius: 0;
  height: auto;
  line-height: 1.4;
  min-width: auto;
  width: auto;
  margin: 0;
}
.cw-tab:hover { background: #e8f0fe; color: #1875d0; }
.cw-tab.active {
  background: #1875d0;
  color: #fff;
}
.cw-tab.active:hover { background: #1565b8; color: #fff; }

/* --- Word Input Row --- */
.cw-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.cw-input-row input[type="text"] {
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cw-input-row input[type="text"]:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}
.cw-input-row .cw-word-input { flex: 1; }
.cw-input-row .cw-clue-input { flex: 2; }

/* --- Bulk Entry --- */
#bulkInput {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  box-sizing: border-box;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#bulkInput:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}
.cw-input-row button {
  flex-shrink: 0;
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 38px;
}

/* --- Word List --- */
.cw-word-list {
  margin-top: 12px;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cw-word-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f5f7fa;
  border: 1px solid #e0e4ea;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.4;
}
.cw-word-item .cw-word-text {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #2c3e50;
}
.cw-word-item .cw-word-dash {
  color: #aaa;
  margin: 0 6px;
}
.cw-word-item .cw-word-clue {
  color: #777;
}
.cw-word-item .cw-delete-btn {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  margin-left: 8px;
  min-width: auto;
  width: auto;
  height: auto;
}
.cw-word-item .cw-delete-btn:hover {
  color: #c62828;
  background: rgba(198, 40, 40, 0.08);
}

/* --- Action Bar --- */
.cw-action-bar {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.cw-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 0.88rem;
  color: #666;
  cursor: pointer;
  user-select: none;
}
.cw-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #1875d0;
  cursor: pointer;
}
.cw-warning {
  margin-top: 10px;
  font-size: 0.88rem;
  color: #999;
}
#cw-setup-error {
  color: #c62828;
  font-size: 0.9rem;
  margin-top: 8px;
  display: none;
}

/* --- Screen Toggle (match winner pattern) --- */
.cw-screen { display: none; }
.cw-screen.active { display: block; }

/* --- Puzzle Output Section --- */
.cw-puzzle-section {
  max-width: 800px;
  margin: 0 auto;
  padding: 10px 20px 60px;
  text-align: center;
}
.cw-puzzle-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}
.cw-puzzle-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

/* --- Grid --- */
.crossword-grid {
  display: inline-grid;
  border: 2px solid #000;
}
.cw-grid-cell {
  position: relative;
  border: 1px solid #000;
}
.cw-grid-cell.black {
  background: hsl(20, 5%, 85%);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.cw-grid-cell.white {
  background: #fff;
}
.cw-cell-number {
  position: absolute;
  top: 1px;
  left: 2px;
  font-family: 'Open Sans', Arial, sans-serif;
  line-height: 1;
  color: #333;
}
.cw-cell-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Open Sans', Arial, sans-serif;
  font-weight: 600;
  color: #333;
}

/* --- Clues --- */
.cw-clues-container {
  width: 100%;
  max-width: 600px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  text-align: left;
}
@media (max-width: 500px) {
  .cw-clues-container { grid-template-columns: 1fr; }
}
.cw-clues-container h3 {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #2c3e50;
  margin-bottom: 10px;
}
.cw-clues-container ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cw-clues-container li {
  font-size: 0.88rem;
  line-height: 1.5;
}
.cw-clue-number {
  font-weight: 600;
  color: #888;
  margin-right: 4px;
}

/* --- Interactive Puzzle Inputs --- */
.cw-cell-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-family: 'Open Sans', Arial, sans-serif;
  font-weight: 600;
  color: #333;
  text-transform: uppercase;
  caret-color: #1875d0;
  outline: none;
  padding: 0;
  box-sizing: border-box;
}
.cw-cell-input:focus {
  background: rgba(24, 117, 208, 0.08);
}
.cw-cell-input.correct {
  color: #1b7a3d;
}
.cw-cell-input.incorrect {
  color: #c62828;
}
.cw-grid-cell.cw-cell-correct {
  background: #d4edda;
}
.cw-grid-cell.cw-cell-incorrect {
  background: #f8d7da;
}
.cw-grid-cell.cw-active-cell {
  background: #e8f0fe;
}
.cw-grid-cell.cw-active-cell.cw-cell-correct {
  background: #d4edda;
}
.cw-grid-cell.cw-active-cell.cw-cell-incorrect {
  background: #f8d7da;
}

/* --- Interactive Clue Highlighting --- */
.cw-clue-item {
  transition: background 0.15s;
  padding: 3px 6px;
  border-radius: 4px;
}
.cw-clue-item:hover {
  background: #f0f4f8;
}
.cw-clue-item.cw-clue-highlight {
  background: #e8f0fe;
  font-weight: 600;
}

/* --- Interactive Button Bar --- */
.cw-interactive-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.cw-progress {
  font-size: 0.88rem;
  color: #888;
  margin-left: 8px;
}

/* --- Completion Message --- */
.cw-completion-msg {
  margin-top: 20px;
  padding: 16px 24px;
  background: #d4edda;
  border: 1px solid #c3e6cb;
  border-radius: 10px;
  color: #155724;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .crossword_setup_card { padding: 20px 16px; }
  .cw-input-row { flex-wrap: wrap; }
  .cw-input-row .cw-word-input,
  .cw-input-row .cw-clue-input { flex: 1 1 100%; }
}

/* --- Print Styles --- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff !important; }
  .cw-puzzle-section { padding: 0; max-width: none; }
  .cw-puzzle-title { margin-top: 1rem; }
  .cw-grid-cell.black {
    background: hsl(20, 5%, 85%) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .footer { display: none !important; }

  @page {
    margin-top: 10mm;
    margin-bottom: 10mm;
  }
  title { display: none; }
}
