/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', Arial, sans-serif;
  background: #fff9f0;
  background-image:
    radial-gradient(circle at 15% 20%, #ffe0f0 0%, transparent 35%),
    radial-gradient(circle at 85% 75%, #d0eeff 0%, transparent 35%),
    radial-gradient(circle at 50% 50%, #fffbe0 0%, transparent 60%);
  min-height: 100vh;
  color: #222;
  padding: 1.5rem;
}

/* ─── Controls ─────────────────────────────────────────────────────────────── */
.controls {
  max-width: 620px;
  margin: 0 auto 1.5rem;
  background: #fff;
  border-radius: 20px;
  padding: 1.5rem 1.75rem;
  border: 3px solid #222;
  box-shadow: 6px 6px 0 #222;
}

.controls h1 {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.2rem;
  text-align: center;
  letter-spacing: .01em;
  color: #ff5c8a;
  text-shadow: 2px 2px 0 #ffd6e7;
}

.controls .subtitle {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 400;
  color: #888;
  margin-bottom: 1.1rem;
  letter-spacing: 0.02em;
}

fieldset {
  border: 2.5px solid #222;
  border-radius: 14px;
  padding: .7rem 1rem .85rem;
  margin-bottom: 1rem;
  background: #f8f4ff;
}

legend {
  font-size: .75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #7c3aed;
  padding: 0 .4rem;
  background: #f8f4ff;
  border-radius: 4px;
}

/* ─── Toggle button group ───────────────────────────────────────────────────── */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .55rem;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .4rem 1.1rem;
  border: 2.5px solid #222;
  border-radius: 50px;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 700;
  font-family: inherit;
  background: #fff;
  transition: background .12s, transform .1s, box-shadow .1s;
  user-select: none;
  box-shadow: 3px 3px 0 #222;
}

.btn input[type="radio"] {
  display: none;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #222;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #222;
}

.btn.active {
  background: #ff5c8a;
  color: #fff;
  border-color: #222;
}

/* ─── Toggle checkbox ───────────────────────────────────────────────────────── */
label.toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  margin-top: .5rem;
  margin-right: .75rem;
}

label.toggle input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  cursor: pointer;
  accent-color: #7c3aed;
}

/* ─── Action buttons ────────────────────────────────────────────────────────── */
.action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: .4rem;
  margin-bottom: 1.2rem;
  justify-content: center;
}

.primary-btn,
.secondary-btn {
  padding: .55rem 1.4rem;
  border: 2.5px solid #222;
  border-radius: 50px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  font-weight: 900;
  transition: transform .1s, box-shadow .1s;
  box-shadow: 4px 4px 0 #222;
}

.primary-btn {
  background: #ffce00;
  color: #222;
}

.secondary-btn {
  background: #00c9a7;
  color: #fff;
}

.primary-btn:hover,
.secondary-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 #222;
}

.primary-btn:active,
.secondary-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #222;
}

/* ─── Error ─────────────────────────────────────────────────────────────────── */
.error {
  max-width: 620px;
  margin: 0 auto 1.2rem;
  background: #fff0f0;
  border: 2.5px solid #ff5c8a;
  border-radius: 14px;
  padding: .8rem 1.1rem;
  color: #c0003c;
  font-size: .9rem;
  font-weight: 700;
  box-shadow: 4px 4px 0 #ffd6e7;
}

/* ─── Board ─────────────────────────────────────────────────────────────────── */
.board-wrapper {
  display: flex;
  justify-content: center;
}

.board {
  border-collapse: separate;
  border-spacing: 5px;
  table-layout: fixed;
  width: min(100%, 860px);
}

/* Cycle through five bright pastel backgrounds for each column */
.board tr td:nth-child(5n+1) { --cell-bg: #fff5cc; }
.board tr td:nth-child(5n+2) { --cell-bg: #ffe0f5; }
.board tr td:nth-child(5n+3) { --cell-bg: #d6f0ff; }
.board tr td:nth-child(5n+4) { --cell-bg: #e8ffd6; }
.board tr td:nth-child(5n+5) { --cell-bg: #f0e4ff; }

.cell {
  background: var(--cell-bg, #fff5cc);
  border: 2.5px solid #222;
  border-radius: 14px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  padding: .4rem;
  aspect-ratio: 1;
  transition: transform .12s, box-shadow .12s, background .15s;
  position: relative;
  overflow: hidden;
  box-shadow: 3px 3px 0 #bbb;
}

.cell:hover {
  transform: translate(-2px, -2px) scale(1.03);
  box-shadow: 5px 5px 0 #999;
}

.cell.marked {
  background: #b6f0b6 !important;
  border-color: #2a9d2a;
  box-shadow: 3px 3px 0 #2a9d2a;
}

.cell.marked::after {
  content: "✓";
  position: absolute;
  top: 3px;
  right: 7px;
  font-size: 1.1rem;
  font-weight: 900;
  color: #2a9d2a;
  pointer-events: none;
}

.cell-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  height: 100%;
  justify-content: center;
}

.cell-inner img {
  max-width: 100%;
  max-height: 65%;
  object-fit: contain;
  display: block;
}

.cell-name {
  font-size: clamp(.55rem, 1.2vw, .82rem);
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
  color: #333;
}

.cell-color {
  font-size: clamp(.45rem, .9vw, .68rem);
  font-weight: 700;
  color: #7c3aed;
  font-style: italic;
  text-align: center;
}

/* ─── Slider ─────────────────────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .55rem;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: #7c3aed;
  cursor: pointer;
}

.slider-row span {
  font-size: 1rem;
  font-weight: 900;
  min-width: 1.5rem;
  text-align: center;
  color: #7c3aed;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  margin-top: 2rem;
  font-size: .8rem;
  color: #888;
}

footer .version {
  display: block;
  font-size: .7rem;
  color: #bbb;
  margin-top: .25rem;
}

footer a {
  color: #7c3aed;
  text-decoration: none;
  font-weight: 700;
}

footer a:hover {
  text-decoration: underline;
}
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  .board-wrapper { display: block; width: 277mm; height: 190mm; }
  .board { width: 277mm; height: 190mm; table-layout: fixed; border-collapse: collapse; border-spacing: 0; }
  .cell { border: 1.5pt solid #000; border-radius: 0; padding: 3pt; box-shadow: none; transform: none;
          -webkit-print-color-adjust: exact; print-color-adjust: exact;
          overflow: hidden; vertical-align: middle; text-align: center; }
  .cell.marked { background: #ccc !important; }
  .cell.marked::after { display: none; }
  .cell:hover { transform: none; }
  .cell-name { font-size: 8pt; }
  .cell-color { font-size: 6.5pt; }
}
