.color-sweeper-shell {
  --game-accent: var(--g-sweeper);
  --board-line: var(--mambo-board-line);
  --cell: var(--mambo-cell);
  /* Fill colours; each also carries a small shape so they can be told apart without colour. */
  --cs-0: #3b82d6;
  --cs-1: #ee8a3a;
  --cs-2: #3a9f64;
  --cs-3: #9466d4;
  --cs-ink: rgb(0 0 0 / 0.28);
}
:root[data-theme='dark'] .color-sweeper-shell {
  --cs-0: #4c93e6;
  --cs-1: #f09a4f;
  --cs-2: #4cb577;
  --cs-3: #a57be0;
  --cs-ink: rgb(0 0 0 / 0.32);
}
.color-sweeper-shell .shell-stage {
  gap: 20px;
  padding: 0 var(--space-4);
}
.color-sweeper-shell .shell-board-area {
  width: 100%;
}
.color-sweeper-shell .color-board-wrap {
  width: min(560px, calc(100vw - 32px), calc(100dvh - 240px));
  margin: 0 auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
}
.color-sweeper-shell .color-board {
  --gap: 3px;
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(var(--color-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--color-rows), minmax(0, 1fr));
  gap: var(--gap);
  aspect-ratio: var(--color-columns) / var(--color-rows);
  padding: var(--gap);
  border-radius: 10px;
  background: var(--board-line);
}
.color-sweeper-shell .color-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--cell);
  color: var(--text);
  font: 800 calc(100cqw / var(--color-columns) * 0.36) / 1 var(--font-app);
  box-shadow: none;
  filter: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 120ms ease-out;
}
.color-sweeper-shell .color-board > :first-child {
  border-top-left-radius: 7px;
}
.color-sweeper-shell .color-cell:hover:not(:disabled) {
  filter: brightness(0.96);
}
.color-sweeper-shell .color-cell:active:not(:disabled) {
  transform: scale(0.96);
}
.color-sweeper-shell .color-cell:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 2px var(--text);
}
.color-sweeper-shell .color-cell.color-0 {
  --fill: var(--cs-0);
}
.color-sweeper-shell .color-cell.color-1 {
  --fill: var(--cs-1);
}
.color-sweeper-shell .color-cell.color-2 {
  --fill: var(--cs-2);
}
.color-sweeper-shell .color-cell.color-3 {
  --fill: var(--cs-3);
}
.color-sweeper-shell .color-cell[class*='color-']:not(.empty) {
  background: var(--fill);
  border: 0;
}
/* Shape cue per colour: circle, triangle, square, diamond. */
.color-sweeper-shell .color-glyph {
  display: block;
  width: 28%;
  aspect-ratio: 1;
  background: var(--cs-ink);
}
.color-sweeper-shell .color-0 .color-glyph {
  border-radius: 50%;
}
.color-sweeper-shell .color-1 .color-glyph {
  clip-path: polygon(50% 8%, 96% 92%, 4% 92%);
}
.color-sweeper-shell .color-2 .color-glyph {
  border-radius: 2px;
}
.color-sweeper-shell .color-3 .color-glyph {
  width: 24%;
  transform: rotate(45deg);
}
/* Clue numbers sit on the clue's colour inside a white badge, readable in both themes. */
.color-sweeper-shell .color-cell.given {
  cursor: default;
  opacity: 1;
}
.color-sweeper-shell .color-cell.given strong {
  display: grid;
  width: 62%;
  height: 62%;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: #121212;
  box-shadow: none;
}
.color-sweeper-shell .color-cell.given strong span {
  line-height: 1;
}
.color-sweeper-shell .color-cell.trial-change {
  box-shadow: inset 0 0 0 3px var(--g-chromedoku);
}
.color-sweeper-shell .color-cell.hinted {
  outline: 3px solid var(--hint-target);
  outline-offset: -3px;
}
.color-sweeper-shell .color-cell.hint-source {
  outline: 3px solid var(--hint-context);
  outline-offset: -3px;
}
.color-sweeper-shell .color-cell.hint-target {
  outline: 3px solid var(--hint-target);
  outline-offset: -3px;
  background: color-mix(in srgb, var(--hint-target) 25%, var(--cell));
}
/* Chain hints: a cell assumed or forced so far shows its colour as a dashed ghost, not a real fill. */
.color-sweeper-shell .color-ghost {
  display: grid;
  width: 72%;
  height: 72%;
  place-items: center;
  border: 2px dashed var(--fill);
  border-radius: 6px;
  background: color-mix(in srgb, var(--fill) 45%, transparent);
}
.color-sweeper-shell .color-ghost.color-0 {
  --fill: var(--cs-0);
}
.color-sweeper-shell .color-ghost.color-1 {
  --fill: var(--cs-1);
}
.color-sweeper-shell .color-ghost.color-2 {
  --fill: var(--cs-2);
}
.color-sweeper-shell .color-ghost.color-3 {
  --fill: var(--cs-3);
}
.color-sweeper-shell .color-ghost .color-glyph {
  width: 38%;
}
/* The clue that breaks under the assumption. */
.color-sweeper-shell .color-cell.hint-contradiction {
  outline: 3px solid var(--danger);
  outline-offset: -3px;
}
.color-sweeper-shell .color-cell.hint-contradiction strong {
  box-shadow: 0 0 0 3px var(--danger);
}
.color-sweeper-shell .color-cell.conflict:not(.given) {
  box-shadow: inset 0 0 0 3px var(--danger);
}
.color-sweeper-shell .color-cell.just-set .color-glyph {
  animation: cs-pop 160ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.color-sweeper-shell .color-cell.just-set {
  animation: cs-fill 160ms ease-out;
}
@keyframes cs-pop {
  from {
    transform: scale(0.3);
  }
}
@keyframes cs-fill {
  from {
    filter: brightness(1.25);
  }
}
.color-sweeper-shell .color-board.shake {
  animation: cs-shake 240ms ease-in-out;
}
@keyframes cs-shake {
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}
.color-sweeper-shell .color-board.solved .color-cell {
  animation: cs-solved 520ms ease-out both;
  animation-delay: calc(var(--i) * 45ms);
}
@keyframes cs-solved {
  40% {
    transform: scale(0.88);
    filter: brightness(1.2);
  }
}

/* Colour picker under the board, same segmented look as Mambo. */
.color-sweeper-shell .shell-input {
  min-height: 0;
  padding: 0;
}
.color-sweeper-shell .color-palette {
  display: grid;
  grid-template-columns: repeat(var(--swatches), 60px);
  gap: 4px;
  width: max-content;
  margin: 0;
  padding: 4px;
  border-radius: 14px;
  background: var(--mambo-segment-bg);
}
.color-sweeper-shell .color-palette button {
  display: grid;
  width: 60px;
  height: 48px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.color-sweeper-shell .color-palette button.selected {
  background: var(--segment-on);
  box-shadow:
    0 1px 3px rgb(0 0 0 / 0.2),
    inset 0 0 0 1.5px var(--game-accent);
}
.color-sweeper-shell .color-chip {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 7px;
  background: var(--fill);
}
.color-sweeper-shell .color-palette .color-0 {
  --fill: var(--cs-0);
}
.color-sweeper-shell .color-palette .color-1 {
  --fill: var(--cs-1);
}
.color-sweeper-shell .color-palette .color-2 {
  --fill: var(--cs-2);
}
.color-sweeper-shell .color-palette .color-3 {
  --fill: var(--cs-3);
}
.color-sweeper-shell .color-chip .color-glyph {
  width: 11px;
}
.color-sweeper-shell .color-palette svg {
  width: 22px;
  height: 22px;
}

.color-sweeper-shell .color-hint-steps {
  margin: var(--space-2) 0 var(--space-3);
  padding-left: 1.2em;
  line-height: 1.6;
}
.shell-loading {
  display: grid;
  gap: var(--space-4);
  place-items: center;
  min-height: 200px;
  color: var(--text-muted);
  text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .color-sweeper-shell .color-cell,
  .color-sweeper-shell .color-cell.just-set,
  .color-sweeper-shell .color-cell.just-set .color-glyph,
  .color-sweeper-shell .color-board.shake,
  .color-sweeper-shell .color-board.solved .color-cell {
    animation: none;
    transition: none;
  }
}

/* Assist: finished clues fade so the open ones stand out. */
.color-sweeper-shell .color-cell.given.settled strong {
  opacity: 0.4;
}
