body {
  font-family: system-ui, sans-serif;
  margin: 0;
  background: #f5f5f5;
  color: #222;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.camera {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 60% of the shorter side; keep in sync with GUIDE_FRACTION in js/app.js */
.guide {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 60%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 3px solid #00e676;
  background-image:
    linear-gradient(to right, rgba(0, 230, 118, 0.5) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 230, 118, 0.5) 1px, transparent 1px);
  background-size: 25% 25%;
  pointer-events: none;
}

.guide[hidden] {
  display: none;
}

.controls {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

button {
  font: inherit;
  padding: 0.6rem 1.2rem;
}

#result img {
  max-width: 100%;
  max-height: 60vh;
  display: block;
  margin-bottom: 0.5rem;
}

.print-page main {
  max-width: 900px;
}

#grids {
  --cell: 2cm; /* set from the size selector in js/print.js */
  display: flex;
  flex-wrap: wrap;
  gap: 1cm;
}

figure {
  margin: 0;
  text-align: center;
  break-inside: avoid;
}

.print-grid {
  display: grid;
  grid-template-columns: repeat(4, var(--cell));
  grid-template-rows: repeat(4, var(--cell));
  width: calc(4 * var(--cell));
  outline: 2px solid #999;
  outline-offset: 6px;
  margin: 8px;
  background: #fff;
}

.cell.black {
  background: #000;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

@media print {
  @page {
    margin: 1cm;
  }

  body {
    background: #fff;
  }

  .no-print {
    display: none;
  }

  .print-page main {
    max-width: none;
    padding: 0;
  }

  #grids {
    gap: 0.8cm;
  }
}
