/* Masyu (pearls) board — archetype 06, "mark-the-grid", scoped under .masyu-root.
   A square grid of cells; the player draws a single closed loop through the cell
   centres by tapping the lines between neighbouring cells. Some cells carry a white
   or black pearl. Uses the shared design tokens (gold accent + warm neutrals);
   light + dark via .mode-dark. */

.masyu-root {
  --cell: 48px;
  --line: #d7cfbe; --ink: #2a2620; --paper: #fbf9f3;
  --dot: #c8bfa8;
  --loop: #2f2b24; --loop-soft: #b9ad90;
  --gold: #b68235; --gold-soft: #e7d3a3;
  --pearl-ring: #2f2b24; --pearl-fill: #fbf9f3; --pearl-black: #24211b;
  --bad: #c8503b; --done: #5c8a4a;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(12px, 3vw, 22px);
  padding: clamp(10px, 2.5vw, 22px) 0;
  color: var(--ink);
}
/* Board tonality is fixed by the surface panel (BOARD_SURFACES.md): the board
   follows our .mode-dark class only, never the OS colour-scheme. */
.masyu-root.mode-dark {
  --line: #3a4030; --ink: #ece8e2; --paper: #262a21;
  --dot: #454b39;
  --loop: #e9e3d5; --loop-soft: #55503f;
  --gold: #d8b65c; --gold-soft: #4a4126;
  --pearl-ring: #e9e3d5; --pearl-fill: #1c1f18; --pearl-black: #0c0d09;
  --bad: #d9694f; --done: #7dab68;
}

.masyu-board {
  position: relative;
  inline-size: calc(var(--n) * var(--cell));
  block-size: calc(var(--n) * var(--cell));
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-sizing: content-box;
  touch-action: manipulation;
}

/* Guide dots at every cell centre; pearls replace them where a circle sits. */
.masyu-dot {
  position: absolute;
  transform: translate(-50%, -50%);
  inline-size: calc(var(--cell) * 0.18);
  block-size: calc(var(--cell) * 0.18);
  border-radius: 50%;
  background: var(--dot);
  z-index: 3;
  pointer-events: none;
}
.masyu-dot.pearl {
  inline-size: calc(var(--cell) * 0.62);
  block-size: calc(var(--cell) * 0.62);
  box-sizing: border-box;
}
.masyu-dot.pearl.white {
  background: var(--pearl-fill);
  border: calc(var(--cell) * 0.11) solid var(--pearl-ring);
}
.masyu-dot.pearl.black {
  background: var(--pearl-black);
  border: calc(var(--cell) * 0.06) solid var(--pearl-ring);
}
.masyu-dot.pearl.bad {
  border-color: var(--bad);
  box-shadow: 0 0 0 2px var(--bad);
}

/* Clickable line between two neighbouring cells. Transparent hotspot; the drawn
   loop segment lives in the inner .masyu-seg. */
.masyu-edge {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0; margin: 0; border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 4;
  display: grid; place-items: center;
}
.masyu-edge.h { inline-size: calc(var(--cell) * 0.82); block-size: calc(var(--cell) * 0.46); }
.masyu-edge.v { inline-size: calc(var(--cell) * 0.46); block-size: calc(var(--cell) * 0.82); }

.masyu-seg {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: var(--loop-soft);
  opacity: 0;
  transition: opacity 0.1s ease;
}
.masyu-edge.h .masyu-seg { inline-size: calc(var(--cell) + 2px); block-size: calc(var(--cell) * 0.15); }
.masyu-edge.v .masyu-seg { inline-size: calc(var(--cell) * 0.15); block-size: calc(var(--cell) + 2px); }

/* Hover previews the segment faintly (pointer devices only). */
@media (hover: hover) {
  .masyu-edge:hover .masyu-seg { opacity: 0.32; }
}
.masyu-edge.on .masyu-seg {
  opacity: 1;
  background: var(--loop);
}

.masyu-root.solved .masyu-board { border-color: var(--done); }
.masyu-root.solved .masyu-edge.on .masyu-seg { background: var(--gold); }

@media (prefers-reduced-motion: reduce) { .masyu-seg { transition: none; } }
.masyu-root.no-motion .masyu-seg { transition: none; }
