:root {
  --paper: #f4f1eb;
  --ink: #1c1c1c;
  --muted: #5e5a55;
  --line: #cfc8be;
  --ok: #166534;
  --bad: #9a3412;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Lexend, "Segoe UI", system-ui, sans-serif;
}

body { padding: 24px 14px 48px; }

#app { width: min(860px, 100%); margin: 0 auto; }

h1, h2, p { margin: 0; }

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 { font-size: clamp(32px, 5vw, 44px); margin-top: 6px; }

.lead {
  margin: 12px 0 22px;
  max-width: 46ch;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

.op {
  display: grid;
  gap: 6px;
  min-height: 140px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}

.op strong { font-size: 22px; }
.op small { color: var(--muted); font-size: 14px; font-weight: 600; }

.sheet {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 16px 16px;
}

.head {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.field { display: grid; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }

.field input {
  min-height: 40px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  font: inherit;
  font-size: 18px;
  color: var(--ink);
}

.novo, .check, .back, .pdf {
  font: inherit;
  cursor: pointer;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  font-weight: 700;
}

.check, .back { background: white; color: var(--ink); }

h2 {
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.instruction { color: var(--muted); margin-bottom: 16px; font-size: 16px; }

.rows { display: grid; gap: 12px; }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
}

.plus { font-size: 22px; font-weight: 700; }

.term {
  min-width: 48px;
  font-size: 28px;
  font-weight: 700;
  text-align: right;
}

.note, .coin {
  display: inline-grid;
  place-items: center;
  border: 2px solid var(--ink);
  font-weight: 700;
  line-height: 1;
}

.note {
  width: 92px;
  height: 48px;
  border-radius: 6px;
  background: var(--tone, #e8eef8);
  font-size: 18px;
}

.coin {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--tone, #f3e2b3);
  font-size: 13px;
}

.box {
  width: 92px;
  height: 48px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  text-align: center;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
}

.box.ok { border-color: var(--ok); background: #e8f6ee; color: var(--ok); }
.box.bad { border-color: var(--bad); background: #fff1e8; }

.sqs { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }

.sq {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid rgba(0, 0, 0, 0.35);
  display: block;
}

.example { color: var(--muted); font-size: 13px; font-weight: 700; }

.actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }

.pdf { background: white; color: var(--ink); }

.feedback { min-height: 24px; margin-top: 10px; font-weight: 700; }

.hunt {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: start;
}

.board {
  display: grid;
  gap: 2px;
  width: min(100%, 460px);
  user-select: none;
  touch-action: none;
}

.cell {
  aspect-ratio: 1;
  border: 0;
  background: #f7f5f2;
  font: inherit;
  font-size: clamp(12px, 2vw, 16px);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.cell.on { background: #d9e4f5; }
.cell.hit { background: #dcecdd; }

.words {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  align-content: start;
  gap: 8px;
}

.words li {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.words li.done {
  color: var(--ok);
  text-decoration: line-through;
  background: #e8f6ee;
}

button:focus-visible, input:focus-visible {
  outline: 3px solid #1d4e89;
  outline-offset: 3px;
}

@media (min-width: 760px) {
  .rows.cols {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(var(--lines), auto);
    grid-auto-flow: column;
    column-gap: 28px;
  }
}

@media (max-width: 759px) {
  body { padding: 16px 12px calc(28px + env(safe-area-inset-bottom)); }
  .lead { font-size: 16px; }
  .head { grid-template-columns: 1fr 1fr; }
  .novo { grid-column: 1 / -1; width: 100%; }
  .op { min-height: 0; padding: 14px; }
  .op strong { font-size: 20px; }
  .sheet { padding: 14px 12px; }
  .actions { flex-wrap: wrap; }
  .actions > * { flex: 1 1 30%; }
  .term { min-width: 0; font-size: clamp(20px, 6.2vw, 28px); }
  .plus { font-size: clamp(18px, 5vw, 22px); }
  .box { width: 68px; height: 44px; font-size: 18px; }
  .note { width: 64px; height: 40px; font-size: 16px; }
  .coin { width: 40px; height: 40px; }
  .sq { width: 22px; height: 22px; }
  .sqs { max-width: 42%; }
  .hunt { grid-template-columns: 1fr; }
  .board { width: 100%; }
  .words { grid-template-columns: repeat(auto-fill, minmax(108px, max-content)); }
}

@media (max-width: 380px) {
  .head { grid-template-columns: 1fr; }
  .row { gap: 6px; padding: 8px 0; }
}

@page { size: A4; margin: 0; }

@media print {
  html, body {
    width: 210mm;
    height: 297mm;
    margin: 0 !important;
    padding: 0 !important;
    background: white;
  }
  #app { width: auto; margin: 0; }
  .sheet {
    width: 210mm;
    height: 297mm;
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: 10mm 12mm 12mm;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .head, .date, .actions, .feedback, .novo, .back, .check, .pdf { display: none !important; }
  h2 { font-size: 16pt; margin: 0 0 2mm; }
  .instruction { font-size: 10pt; margin: 0 0 4mm; }
  .rows {
    flex: 1;
    min-height: 0;
    gap: 0 10mm;
    grid-template-rows: repeat(var(--lines), minmax(0, 1fr));
    align-items: center;
  }
  .rows.cols {
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: column;
  }
  .row { padding: 0; gap: 2mm; border-top: 0; }
  .rows:not(.cols) .row > .plus:last-of-type { margin-left: auto; }
  .term { min-width: 12mm; font-size: 16pt; }
  .plus { font-size: 16pt; }
  .box { width: 22mm; height: 9mm; font-size: 14pt; border-width: 1.5px; }
  .note { width: 18mm; height: 9mm; font-size: 11pt; }
  .coin { width: 9mm; height: 9mm; font-size: 9pt; }
  .sqs { max-width: 42mm; gap: 1mm; }
  .sq { width: 6mm; height: 6mm; }
  .example { font-size: 9pt; }
  .hunt {
    flex: 1;
    min-height: 0;
    grid-template-columns: 168mm 1fr;
    align-items: start;
    gap: 6mm;
  }
  .board { width: 168mm; }
  .cell { border: 1px solid #bbb; background: white; font-size: 11pt; }
  .words { gap: 2mm; }
  .note, .coin, .sq, .words li.done, .box.ok {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
