/* sudokuplace.com -- unified stylesheet for the whole rebuilt site (online
   sudoku game + content pages: articles, FAQ, variant puzzle sheets).
   Palette taken from the site's real site.css (body #EEEEFF, topper
   white-on-#6666FF, navbar #CCCCCC) -- same palette as 6x6/12x12sudoku.com. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: #EEEEFF;
  font-family: Arial, Helvetica, sans-serif;
  color: #000;
  line-height: 1.5;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  border: 4px solid #000;
  background-color: #fff;
}

.topper {
  color: #FFFFFF;
  background-color: #6666FF;
  text-align: center;
  padding: 0.5rem;
}

.topper h1 {
  margin: 0;
  font-size: 1.5rem;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
}

.navbar {
  background-color: #CCCCCC;
  width: 160px;
  flex-shrink: 0;
  padding: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.navbar h2 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
}

.navbar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.navbar li {
  margin-bottom: 0.4rem;
}

/* ---- Content pages (articles, FAQ, variant sheet listings) ---- */

.content {
  flex: 1;
  min-width: 0;
  padding: 1.25rem 1.5rem;
}

.content h2 {
  margin-top: 1.5rem;
}

.content h2:first-child {
  margin-top: 0;
}

.content img {
  max-width: 100%;
  height: auto;
}

.content table {
  border-collapse: collapse;
}

.center {
  text-align: center;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.25rem 1.5rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}

.sheet-grid li {
  padding: 0.1rem 0;
}

.sheet-group {
  margin-bottom: 1.5rem;
}

.sheet-group h3 {
  margin-bottom: 0.4rem;
}

.back-link {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: 0.9rem;
}

/* ---- Online sudoku game page ---- */

.board-area {
  flex: 1;
  min-width: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --grid-size / --box-rows / --box-cols are set inline by sudoku-engine.js
   so this same rule set works for any grid size. */
.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 40px);
  grid-template-rows: repeat(var(--grid-size), 40px);
  border: 3px solid #000;
  border-style: double;
}

.sudoku-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid #000;
  font-weight: bolder;
  font-size: 1.1rem;
}

.sudoku-cell.box-top {
  border-top-style: double;
  border-top-width: 3px;
}
.sudoku-cell.box-bottom {
  border-bottom-style: double;
  border-bottom-width: 3px;
}
.sudoku-cell.box-left {
  border-left-style: double;
  border-left-width: 3px;
}
.sudoku-cell.box-right {
  border-right-style: double;
  border-right-width: 3px;
}

.sudoku-given {
  color: #000;
}

/* Empty cells are buttons (not text inputs) that open the number-picker
   popover below, rather than triggering the OS on-screen keyboard. */
.sudoku-cell-btn {
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  text-align: center;
  background-color: transparent;
  font-family: inherit;
  font-weight: bolder;
  color: blue;
  font-size: 1.1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sudoku-cell-btn:hover {
  background-color: rgba(102, 102, 255, 0.1);
}

.sudoku-cell-btn:focus-visible {
  outline: 2px solid #6666FF;
  outline-offset: -2px;
}

.sudoku-cell.active-cell {
  background-color: rgba(102, 102, 255, 0.18);
}

/* Check-answer feedback: a cell sharing a value with another cell in the
   same row/column/box gets flagged after clicking Check. */
.sudoku-cell.conflict {
  background-color: #FFE0E0;
  box-shadow: inset 0 0 0 2px #C0392B;
}

.sudoku-cell.conflict.sudoku-given,
.sudoku-cell.conflict .sudoku-cell-btn {
  color: #C0392B;
}

.check-status {
  min-height: 1.2em;
  margin: 0.5rem 0 0;
  font-weight: bold;
}

.check-status.check-ok {
  color: #1A7F37;
}

.check-status.check-bad {
  color: #C0392B;
}

/* Number-picker popover: pops up over the tapped cell with the valid
   digits for this grid size, so mobile users never see the OS keyboard. */
.number-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.number-picker {
  position: fixed;
  z-index: 1000;
  background-color: #fff;
  border: 2px solid #6666FF;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  padding: 8px;
}

.number-picker[hidden] {
  display: none;
}

.number-picker-grid {
  display: grid;
  grid-template-columns: repeat(var(--picker-cols), 44px);
  gap: 6px;
}

.number-picker-btn {
  width: 44px;
  height: 44px;
  border: 1px solid #B4D0DC;
  border-radius: 6px;
  background-color: #ECF8FF;
  color: #000;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.number-picker-btn:hover,
.number-picker-btn:focus-visible {
  background-color: #DCF0FF;
  outline: none;
}

.number-picker-clear {
  margin-top: 6px;
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #f4f4f4;
  color: #000;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.number-picker-clear:hover,
.number-picker-clear:focus-visible {
  background-color: #e8e8e8;
  outline: none;
}

.controls {
  margin-top: 1rem;
  text-align: center;
}

.puzzle-label {
  margin: 0 0 0.5rem;
  font-weight: bold;
  font-size: 0.9rem;
}

.controls button {
  font-size: 1rem;
  padding: 0.3rem 0.8rem;
  margin: 0 0.25rem;
  cursor: pointer;
}

.blurb {
  max-width: 480px;
  text-align: center;
  font-size: 0.9rem;
  color: #333;
}

.ad-slot {
  margin-top: 1rem;
  width: 100%;
  max-width: 468px;
  min-height: 60px;
}

@media (max-width: 640px) {
  .layout {
    flex-direction: column;
  }
  .navbar {
    width: 100%;
  }
  .controls button {
    min-height: 44px;
    padding: 0.6rem 1.2rem;
    font-size: 1.05rem;
  }
}

@media (max-width: 460px) {
  /* Default 40px cells need ~398px of width for a 9-wide grid (9*40 +
     borders + padding) and overflow on phone-width screens below that.
     Shrink cells and trim padding so the grid fits without horizontal
     scrolling; the number-picker (above) is what needs to stay
     touch-friendly, and it floats independently of the grid's width. */
  .board-area {
    padding: 0.5rem;
  }
  .sudoku-grid {
    grid-template-columns: repeat(var(--grid-size), 34px);
    grid-template-rows: repeat(var(--grid-size), 34px);
  }
  .sudoku-cell {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }
}
