:root {
  --cell-size: 40px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 12px;
  background: #fafafa;
  color: #1f1f1f;
}

header {
  margin-bottom: 12px;
}

h1 {
  font-size: 20px;
  margin: 0 0 10px;
  letter-spacing: 0.5px;
}

.hint {
  font-size: 12px;
  color: #666;
  margin: 8px 0 0;
  line-height: 1.6;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 14px;
}

.controls input {
  width: 64px;
  padding: 4px 6px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.controls button {
  padding: 6px 14px;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  background: #1f1f1f;
  color: #fff;
  cursor: pointer;
}

.grid-wrap {
  overflow: auto;
  max-height: 50vh;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), var(--cell-size));
  gap: 2px;
  justify-content: start;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: calc(var(--cell-size) * 0.55);
  font-weight: 700;
  text-transform: uppercase;
  user-select: none;
  cursor: pointer;
  background: #fff;
  color: #1f1f1f;
  transition: background 0.12s, color 0.12s;
}

.cell.selected {
  outline: 2px solid #1f6feb;
  outline-offset: 1px;
  z-index: 1;
}

.cell.matching {
  box-shadow: inset 0 0 0 3px #1f6feb;
  z-index: 2;
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.keyboard button {
  padding: 10px 0;
  font-size: 16px;
  font-weight: 600;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.keyboard button:active {
  background: #e6e6e6;
}

.keyboard .wide {
  grid-column: span 2;
}

.word-finder {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.word-finder input {
  flex: 1;
  min-width: 120px;
  padding: 8px 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.word-finder button {
  padding: 8px 14px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

#confirmWord {
  background: #1f1f1f;
  color: #fff;
  border-color: #1f1f1f;
}

.word-status {
  font-size: 13px;
  color: #444;
  margin-top: 6px;
  min-height: 18px;
}

.found-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.found-word {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
}
