html, body {
  height: 100%;
  margin: 0;
  padding: 20px;
  box-sizing: border-box;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;
}

.container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  max-height: 95vh;
  padding: 40px;
  box-sizing: border-box;
  background: #fff;
}

.flex {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  width: 100%;
}

.grid-container {
  flex-shrink: 0;
}

.crossword-grid {
  display: grid;
  grid-template-columns: repeat(16, 32px);
  grid-template-rows: repeat(20, 32px);
  gap: 1px;
  background: #aaa;
  border: 1px solid #aaa;
  width: fit-content;
}

.cell {
  width: 32px;
  height: 32px;
  background: #fff;
  border: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
}

.cell.block {
  background: #222;
  border: none;
  box-shadow: none;
  pointer-events: none;
}

.cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 9px;
  color: #333;
  font-weight: normal;
  z-index: 10;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.cell-input {
  width: 100%;
  height: 100%;
  text-align: center;
  font-size: 16px;
  font-weight: normal;
  background: transparent;
  border: none;
  outline: none;
  text-transform: uppercase;
  caret-color: #000;
  padding: 0;
  margin: 0;
  font-family: 'Helvetica Neue', Arial, sans-serif;
}

.cell.highlight { background: #e8e8e8 !important; }
.cell.current   { background: #ccc !important; }

.clues-section {
  flex: 1;
  max-width: 280px;
  min-width: 200px;
}

.clues-section h3 {
  font-size: 13px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px 0;
  color: #000;
  border-bottom: 1px solid #000;
  padding-bottom: 4px;
}

.clue {
  margin-bottom: 6px;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 13px;
  line-height: 1.5;
  color: #222;
}

.clue.active {
  background: #000;
  color: #fff;
}

.controls {
  margin-top: 20px;
  text-align: left;
}

.btn {
  background: none;
  border: none;
  color: #000;
  padding: 0;
  margin: 0 15px 0 0;
  font-size: 14px;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  cursor: pointer;
  text-decoration: underline;
  border-radius: 0;
  box-shadow: none;
  transition: opacity 0.2s ease;
}

.btn:hover {
  opacity: 0.5;
  background: none;
  text-decoration: underline;
}

.status {
  margin-top: 16px;
  font-size: 16px;
  text-align: left;
}

/* ── Mobile ─────────────────────────────────────────── */
@media (max-width: 900px) {
  html, body {
    display: block;
    padding: 12px;
  }

  .container {
    padding: 12px;
    max-height: none;
    max-width: none;
    overflow-x: hidden;
  }

  .flex {
    flex-direction: column !important;
    align-items: flex-start;
    gap: 20px;
  }

  .grid-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Scale cells so 16 columns fit the viewport (account for 15 gaps of 1px + 2px border) */
  .crossword-grid {
    --cell: min(32px, calc((100vw - 24px - 17px) / 16));
    grid-template-columns: repeat(16, var(--cell));
    grid-template-rows: repeat(20, var(--cell));
  }

  .cell {
    width: var(--cell, 32px);
    height: var(--cell, 32px);
  }

  .cell-number {
    font-size: 7px;
  }

  .cell-input {
    font-size: calc(var(--cell, 32px) * 0.5);
  }

  .clues-section {
    width: 100% !important;
    max-width: none;
    min-width: 0;
  }
}
