.c-board {
  --n: 6;
  --c-thick: rgba(255, 255, 255, .78);
  --c-thin: rgba(255, 255, 255, .08);
  --c-bg: #1c1c1e;
  --c-peer: #242426;
  --c-cage: color-mix(in srgb, var(--game) 14%, #1c1c1e);
  --c-same: color-mix(in srgb, var(--game) 30%, #1c1c1e);
  --c-sel: var(--game);
  --c-cell: calc(100cqw / var(--n));
  container-type: inline-size;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  border: 2px solid var(--c-thick);
  border-radius: 16px;
  overflow: hidden;
  background: var(--c-bg);
  color: #fff;
}
.c-cell {
  position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0;
  border-right: 1px solid var(--c-thin); border-bottom: 1px solid var(--c-thin);
  cursor: pointer; transition: background-color .18s var(--ease-out);
}
.c-cell.c-lc { border-right: 0; }
.c-cell.c-lr { border-bottom: 0; }
.c-cell.c-br { border-right: 2px solid var(--c-thick); }
.c-cell.c-bb { border-bottom: 2px solid var(--c-thick); }
.c-cell.c-peer { background: var(--c-peer); }
.c-cell.c-incage { background: var(--c-cage); }
.c-cell.c-same { background: var(--c-same); }
.c-cell.c-sel { background: var(--c-sel); }
@media (hover: hover) { .c-cell:not(.c-sel):hover { background: #2c2c2e; } }

/* Cage label: target + operation in the top-left corner. */
.c-label {
  position: absolute; top: 3%; left: 6%; z-index: 1; pointer-events: none;
  font-family: var(--font); font-weight: 600; line-height: 1; white-space: nowrap;
  font-size: max(9px, calc(var(--c-cell) * .19)); letter-spacing: -.02em;
  color: rgba(255, 255, 255, .82); padding: 2px 4px; margin: -2px -4px; border-radius: 6px;
  transition: color .2s, background-color .2s;
}
.c-label.c-ok { color: var(--good); background: var(--good-soft); }
.c-label.c-wrong { color: #fff; background: var(--danger); }
.c-label.fx-pop { transform-origin: left top; }

/* Value. */
.c-val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding-top: 12%; pointer-events: none;
  font-family: var(--font); font-weight: 550; line-height: 1; letter-spacing: -0.03em;
  font-size: calc(var(--c-cell) * .46); color: #fff;
}
.c-cell.c-pop .c-val { animation: c-pop .38s var(--ease-spring); }
@keyframes c-pop { from { transform: scale(.55); opacity: .3; } to { transform: scale(1); opacity: 1; } }
.c-cell.c-bad .c-val { color: var(--danger); }
.c-cell.c-bad::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: color-mix(in srgb, var(--danger) 16%, transparent);
}
.c-cell.c-cage-wrong:not(.c-bad)::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--danger) 9%, transparent) 0 4px, transparent 4px 9px);
}

/* Pencil marks, below the cage label. */
.c-notes {
  position: absolute; left: 4%; right: 4%; top: 28%; bottom: 4%; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr;
  font-family: var(--font); color: var(--muted); font-weight: 550; font-size: calc(var(--c-cell) * .19);
}
.c-notes span { display: flex; align-items: center; justify-content: center; line-height: 1; }
.c-cell.c-note-hit .c-notes { color: var(--accent); }

/* Number pad. */
.c-pad { width: min(600px, 100cqw); display: flex; flex-direction: column; gap: 8px; user-select: none; -webkit-user-select: none; }
.c-digits { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: clamp(3px, 1.2vw, 8px); }
.c-key {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0; height: clamp(50px, 13vw, 62px); padding: 0; border-radius: 14px; cursor: pointer;
  border: 0; background: rgba(255, 255, 255, .1); color: #fff; font: inherit;
  touch-action: manipulation; transition: background-color .15s, transform .3s var(--ease-spring), opacity .2s;
}
.c-key:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }
.c-key:active:not(:disabled) { transform: scale(.92); transition-duration: .06s; }
.c-key-d { font-family: var(--font); font-size: clamp(1.2rem, 5vw, 1.5rem); font-weight: 550; line-height: 1; letter-spacing: -0.02em; }
.c-key-c { font-size: .68rem; font-weight: 550; color: var(--muted); line-height: 1; }
.c-key.c-done { opacity: .4; }
.c-key.c-done .c-key-c { color: var(--good); }
.c-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.c-act { padding: 9px 12px; touch-action: manipulation; }
.c-act { background: rgba(255, 255, 255, .1); color: #fff; }
.c-act:hover { background: rgba(255, 255, 255, .16); }
.c-act.c-on, .c-act.c-on:hover { background: #fff; color: #000; }
.c-toggle { font-size: .68rem; font-weight: 650; letter-spacing: .04em; padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, .12); color: var(--muted); }
.c-act.c-on .c-toggle { background: var(--game); color: #fff; }
.c-pad.c-locked { opacity: .55; pointer-events: none; }

/* Teaching hints: the line / cage that explains it, the cells that justify it, the target cell. */
.c-cell.c-hint-area { background: color-mix(in srgb, var(--game) 18%, #1c1c1e); }
.c-cell.c-hint-focus { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
.c-cell.c-hint-target { z-index: 1; box-shadow: inset 0 0 0 3px var(--game); animation: c-hint-pulse 1.1s ease-in-out infinite; }
.c-cell.c-hint-target.c-hint-warn { box-shadow: inset 0 0 0 3px var(--danger); animation-name: c-hint-pulse-warn; }
@keyframes c-hint-pulse { 50% { background-color: color-mix(in srgb, var(--game) 36%, #1c1c1e); } }
@keyframes c-hint-pulse-warn { 50% { background-color: color-mix(in srgb, var(--danger) 30%, #1c1c1e); } }
@media (prefers-reduced-motion: reduce) { .c-cell.c-hint-target { animation: none; } }
