/* Word Search — clean, high-contrast, senior-friendly, mobile-first. No frameworks. */
:root {
  --bg: #f4f1ea; --panel: #fffdf7; --ink: #1f2430; --line: #2b2f3a;
  --thin: #c4cad4; --accent: #2563eb; --accent-soft: #dbe6ff;
  --found: #15803d; --found-soft: #d6f5e0; --preview: #fff0c2;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 14px 14px 40px; }

header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
header h1 { font-size: 1.5rem; margin: 0; letter-spacing: .5px; }
header .sub { flex: 1 1 100%; color: #6b7280; font-size: .92rem; margin: 2px 0 8px; }
.spacer { flex: 1; }
.iconbtn {
  border: 1px solid var(--thin); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font-size: .95rem; cursor: pointer; min-height: 40px;
}
.iconbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; flex-wrap: wrap; }
.toolbar select, .toolbar button {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--thin);
  background: var(--panel); color: var(--ink); font-size: 1rem; padding: 0 14px; cursor: pointer;
}
#newBtn { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.meta { margin-left: auto; display: flex; gap: 16px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.meta b { font-weight: 700; }

/* board: N x N letter grid */
.board {
  --n: 15;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  width: 100%; max-width: 560px; aspect-ratio: 1 / 1; margin: 0 auto;
  background: var(--panel); border: 3px solid var(--line); border-radius: 6px;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.cell {
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--ink); cursor: pointer;
  font-size: clamp(11px, calc(78vw / var(--n)), 30px);
  border-radius: 4px;
}
.cell.preview { background: var(--preview); }
.cell.anchor { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.cell.found { background: var(--found-soft); color: var(--found); }

.status { text-align: center; min-height: 26px; margin: 12px 0; font-weight: 600; }
.status.ok { color: var(--found); font-size: 1.15rem; }

/* word list */
.words {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px 14px; margin: 6px auto 4px; max-width: 560px;
}
.word { font-weight: 700; font-size: 1rem; padding: 2px 0; letter-spacing: .5px; }
.word.done { color: var(--found); text-decoration: line-through; text-decoration-thickness: 2px; opacity: .75; }

.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-width: 560px; margin: 12px auto 0; }
.actions button {
  min-height: 48px; border-radius: 10px; border: 1px solid var(--thin);
  background: var(--panel); color: var(--ink); font-size: 1rem; cursor: pointer;
}

/* large-print mode */
body.large .board { max-width: 100%; }
body.large .cell { font-size: clamp(13px, calc(88vw / var(--n)), 36px); }
body.large .word { font-size: 1.15rem; }

/* book cross-promo */
.book { background: var(--panel); border: 1px solid var(--thin); border-radius: var(--radius);
  padding: 16px; margin: 22px 0 14px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.book h3 { margin: 0 0 4px; font-size: 1.05rem; }
.book p { margin: 0; color: #555; font-size: .92rem; }
.book .grid-ico { width: 54px; height: 54px; flex: none; display: flex; align-items: center;
  justify-content: center; border: 2px solid var(--line); border-radius: 8px;
  font-weight: 800; color: var(--accent); font-size: 1.2rem; }

footer { text-align: center; color: #8a8f9a; font-size: .82rem; margin-top: 18px; }
footer .links a { color: #6b7280; text-decoration: none; margin: 0 6px; }
footer .links a:hover { text-decoration: underline; }
.privacy { margin-top: 6px; }

/* print: board + words only, clean B&W */
@media print {
  body { background: #fff; }
  .toolbar, .actions, .book, footer, header .sub, #langBtn, #largeBtn, .meta, .status { display: none !important; }
  .wrap { max-width: none; }
  header h1 { text-align: center; }
  .board { border-color: #000; max-width: 100%; }
  .cell { color: #000 !important; background: #fff !important; box-shadow: none !important; }
  .word { color: #000 !important; text-decoration: none !important; opacity: 1 !important; }
}
