@font-face {
  font-family: "Amiri";
  src: url("../fonts/Amiri-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Amiri";
  src: url("../fonts/Amiri-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("../fonts/NotoNaskhArabic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("../fonts/NotoNaskhArabic-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #000;
  --paper: #fff;
  --rule: 1px solid #000;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Naskh Arabic", "Amiri", "Noto Naskh Arabic", serif;
  font-size: 18px;
  line-height: 1.55;
}
body { padding: 1.2rem 1rem 3rem; }
::selection { background: #000; color: #fff; }
button, input { font: inherit; color: inherit; background: #fff; }
a { color: inherit; }

.masthead { max-width: 980px; margin: 0 auto 1.2rem; text-align: center; }
.masthead h1 {
  font-family: "Amiri", serif;
  font-weight: 700;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  line-height: 1;
  margin: 0.2rem 0 0.35rem;
  letter-spacing: 0;
}
.rules {
  margin: 0 auto;
  max-width: 46rem;
  border-top: 3px double #000;
  border-bottom: 3px double #000;
  padding: 0.35rem 0 0.45rem;
}
.dateline { margin: 0.35rem 0 0; font-size: 1.05rem; }
.legend {
  margin: 0.45rem auto 0;
  max-width: 46rem;
  font-size: 0.92rem;
  line-height: 1.7;
}
.toolbar, .puzzle-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  margin: 0.8rem 0;
}
button, .toolbar input {
  border: 1px solid #000;
  border-radius: 0;
  padding: 0.35rem 0.7rem;
  background: #fff;
  cursor: pointer;
}
button:hover, button:focus-visible { outline: 2px solid #000; outline-offset: 1px; }
.toolbar input[type="date"] { padding: 0.28rem 0.45rem; }

.stack { max-width: 980px; margin: 0 auto; }
.puzzle {
  border-top: 1px solid #000;
  padding: 1rem 0 1.4rem;
  margin-top: 0.4rem;
}
.puzzle-head { text-align: center; margin-bottom: 0.7rem; }
.puzzle-head h2 {
  font-family: "Amiri", serif;
  font-size: clamp(1.45rem, 3vw, 2rem);
  margin: 0.1rem 0;
  font-weight: 700;
}
.kicker, .diff { margin: 0; font-size: 0.95rem; }
.puzzle-body {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 1.1rem;
}
.board {
  display: grid;
  grid-template-columns: 1.5rem repeat(10, minmax(0, 1fr));
  grid-template-rows: 1.35rem repeat(10, minmax(0, 1fr));
  width: min(100%, 430px);
  aspect-ratio: 11.5 / 11.35;
  flex: 0 0 auto;
}
.frame {
  grid-column: 2 / 12;
  grid-row: 2 / 12;
  border: 1.5px solid #000;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  padding: 2px;
}
.cells {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 1px;
  width: 100%;
  height: 100%;
  background: #000;
  direction: rtl;
}
.cell {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Naskh Arabic", serif;
  font-weight: 700;
  font-size: clamp(0.95rem, 2.4vw, 1.25rem);
  line-height: 1;
  min-width: 0;
  user-select: none;
}
.cell.block { background: #000; }
.cell.selected { outline: 2px solid #000; outline-offset: -3px; }
.cell .user-letter { font-weight: 700; }
.colnum, .rownum, .corner {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Amiri", serif;
  font-size: 0.82rem;
  line-height: 1;
}
.clues { flex: 1 1 240px; min-width: 200px; }
.clues h3 {
  font-family: "Amiri", serif;
  font-size: 1.35rem;
  margin: 0.2rem 0 0.25rem;
  border-bottom: 1px solid #000;
}
.clues p { margin: 0.18rem 0; font-size: 1rem; }
.mini-slot { margin-top: 0.8rem; }
.board.mini {
  width: min(100%, 280px);
  margin-inline: auto;
}
.solution-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: center;
}
.keycatch {
  position: fixed;
  inset-inline-start: 0;
  bottom: 0;
  width: 2rem;
  height: 2rem;
  opacity: 0;
  border: 0;
  padding: 0;
  font-size: 16px;
}

@media (max-width: 800px) {
  body { padding: 0.8rem 0.7rem 2.4rem; font-size: 17px; }
  .puzzle-body, .solution-body { flex-direction: column; align-items: stretch; }
  .board { width: 100%; max-width: 520px; margin-inline: auto; }
  .clues { min-width: 0; }
  .cell { font-size: 1.05rem; }
}

@page { size: A4 portrait; margin: 12mm 25mm 14mm 14mm; }
@media print {
  body { padding: 0; font-size: 12pt; }
  .puzzle-body, .solution-body { flex-direction: row !important; align-items: flex-start !important; }
  .noprint, .toolbar, .puzzle-tools, .keycatch, .legend { display: none !important; }
  .masthead { margin-bottom: 0; }
  .puzzle { break-after: page; border: 0; padding-top: 0; }
  .puzzle:last-child { break-after: auto; }
  body.print-one .puzzle { display: none !important; }
  body.print-one .puzzle.print-target { display: block !important; break-after: auto; }
  body.print-solutions #view-puzzles { display: none !important; }
  body:not(.print-solutions) #view-solutions { display: none !important; }
  .user-letter { color: transparent !important; }
  .board { width: 118mm; aspect-ratio: auto; height: 118mm; }
  .cell { font-size: 12pt; }
  .board.mini { width: 78mm; height: 78mm; }
  .clues p { font-size: 11pt; }
  a { text-decoration: none; }
}
