.numberspan-game .grid-panel {
  --board-width: calc(var(--cell) * 9);

  display: flex;
  flex-direction: column;
  align-items: start;
  width: fit-content;
}

.numberspan-game .grid-wrap {
  background: #ffffff;
  padding: 4px;
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--accent);
  flex-shrink: 0;
  outline: none;
  align-self: start;
  width: calc(var(--board-width) + 14px);
}

.numberspan-game .grid {
  display: grid;
  gap: 0;
  background: transparent;
}

.numberspan-game .cell,
.numberspan-game .hole {
  width: var(--cell);
  height: var(--cell);
  position: relative;
}

.numberspan-game .cell {
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  --cell-top: 0px;
  --cell-right: 0px;
  --cell-bottom: 0px;
  --cell-left: 0px;
}

.numberspan-game .cell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--ink), var(--ink)) left top / 100% var(--cell-top) no-repeat,
    linear-gradient(var(--ink), var(--ink)) right top / var(--cell-right) 100% no-repeat,
    linear-gradient(var(--ink), var(--ink)) left bottom / 100% var(--cell-bottom) no-repeat,
    linear-gradient(var(--ink), var(--ink)) left top / var(--cell-left) 100% no-repeat;
}

.numberspan-game .cell.active {
  background: var(--accent-light);
}

.numberspan-game .cell.locked {
  background: var(--cream);
}

.numberspan-game .cell.clue {
  background: var(--clue-bg);
}

.numberspan-game .cell.has-badge::after {
  content: attr(data-badge);
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.62rem;
  line-height: 1;
  color: var(--badge-color, rgba(36, 22, 27, 0.75));
  z-index: 2;
  pointer-events: none;
}

.numberspan-game .cell.badge-locked {
  --badge-color: rgba(36, 22, 27, 0.75);
}

.numberspan-game .cell.badge-clue {
  --badge-color: var(--clue-border);
}

.numberspan-game .cell.clue input {
  color: var(--clue-ink);
  font-weight: 800;
}

.numberspan-game .cell.invalid {
  background: #ffb3b3;
}

.numberspan-game .cell.duplicate {
  background: #ff9fb3;
}

.numberspan-game .cell.out-of-range {
  background: #ffd1d9;
}

.numberspan-game .cell.invalid input,
.numberspan-game .cell.duplicate input,
.numberspan-game .cell.out-of-range input {
  color: #d40000;
  font-weight: 800;
  text-shadow: 0 0 2px rgba(255, 0, 0, 0.35);
}

.numberspan-game .cell .corner-note {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.62rem;
  line-height: 1;
  color: rgba(36, 22, 27, 0.58);
  z-index: 1;
  pointer-events: none;
}

.numberspan-game .cell input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  font-size: 1.65rem;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  caret-color: transparent;
  position: relative;
  z-index: 1;
}

.numberspan-game .hole {
  background: #ffffff;
  pointer-events: none;
  --hole-top: 0px;
  --hole-right: 0px;
  --hole-bottom: 0px;
  --hole-left: 0px;
}

.numberspan-game .hole::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--ink), var(--ink)) left top / 100% var(--hole-top) no-repeat,
    linear-gradient(var(--ink), var(--ink)) right top / var(--hole-right) 100% no-repeat,
    linear-gradient(var(--ink), var(--ink)) left bottom / 100% var(--hole-bottom) no-repeat,
    linear-gradient(var(--ink), var(--ink)) left top / var(--hole-left) 100% no-repeat;
}


.numberspan-game .debug-textarea {
  width: 100%;
  min-height: 140px;
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: 500 0.82rem/1.45 'IBM Plex Mono', monospace;
}

.numberspan-game .debug-textarea::placeholder {
  color: rgba(36, 22, 27, 0.55);
}

.numberspan-game .controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.numberspan-game .controls button {
  width: 100%;
  grid-column: 1 / -1;
}

.numberspan-game .number-pad-panel {
  width: var(--board-width);
}

.numberspan-game .digit-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
}

.numberspan-game .digit-pad button {
  font-size: 1.4rem;
  padding: 18px 0;
  min-height: 60px;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 0;
  text-transform: none;
}

.numberspan-game .digit-pad button.panel-toggle {
  font-family: 'IBM Plex Mono', monospace, sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.numberspan-game .digit-pad+.controls button {
  width: 100%;
  padding: 16px 0;
  font-size: 0.8rem;
}

.numberspan-game .swatch {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(36, 22, 27, 0.2);
  flex: 0 0 auto;
}

.numberspan-game .swatch.normal {
  background: var(--paper);
}

.numberspan-game .swatch.active {
  background: var(--accent-light);
}

.numberspan-game .swatch.locked {
  background: var(--cream);
}

.numberspan-game .swatch.clue {
  background: var(--clue-bg);
}

.numberspan-game .swatch.hole {
  background: #ffffff;
}

.numberspan-game .hotkey-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.numberspan-game .hotkey-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid rgba(36, 22, 27, 0.12);
  font-size: 0.82rem;
}

.numberspan-game .hotkey-row span {
  color: var(--accent);
  letter-spacing: 0.04em;
}

.numberspan-game .hotkey-row strong {
  color: var(--ink);
  text-align: right;
}

.numberspan-game .rules-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.84rem;
  line-height: 1.6;
}

.numberspan-game .rules-body p {
  background: var(--paper);
  border: 1px solid rgba(36, 22, 27, 0.12);
  padding: 10px 12px;
}

.numberspan-game .overlay-box {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 var(--accent);
  padding: 40px 48px;
  text-align: center;
  max-width: 380px;
  width: 90%;
}