:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #687089;
  --line: #e2e6f0;
  --accent: #4c97ff;      /* синий блок движения, как в Scratch */
  --accent-dark: #3373cc;
  --repeat: #ffab19;      /* оранжевый блок управления, как в Scratch */
  --repeat-dark: #cf8b17;
  --go: #2fbf71;
  --go-dark: #229a5a;
  --bad: #e5484d;
  --warn: #f5a524;
  --wall: #3a4256;
  --cell: #eef2fb;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; border: 0; }
.hidden { display: none !important; }

/* ---------- поле */
.board {
  --size: min(100%, 420px);
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--w), minmax(0, 1fr));
  container-type: inline-size;
  width: var(--size);
  margin: 0 auto;
  gap: 3px;
  background: var(--line);
  padding: 3px;
  border-radius: 14px;
}
.cell {
  aspect-ratio: 1;
  background: var(--cell);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(100cqw / var(--w) * 0.55);
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  line-height: 1;
}
.cell.wall { background: var(--wall); }
.cell.guess { outline: 4px solid var(--repeat); outline-offset: -4px; background: #fff3dc; }
.gem.taken { opacity: .15; transition: opacity .3s; }
.robot {
  position: absolute; left: 3px; top: 3px;
  width: calc((100% - 6px - (var(--w) - 1) * 3px) / var(--w));
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(100cqw / var(--w) * 0.64);
  transition: transform .33s ease;
  pointer-events: none;
  /* шаг сетки = клетка + зазор */
  --step: calc(100% + 3px);
}
.robot { transform: translate(0, 0); }
.robot.bump { animation: bump .45s; }
.robot.win { animation: win .8s; }
@keyframes bump { 0%,100% { filter: none; } 20%,60% { filter: drop-shadow(0 0 6px var(--bad)); } 30% { margin-left: -4px; } 50% { margin-left: 4px; } }
@keyframes win { 0% { scale: 1; } 40% { scale: 1.35; } 100% { scale: 1; } }

/* ---------- блоки */
.blk {
  display: inline-flex; align-items: center; gap: 6px;
  color: #fff; font-weight: 700;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 17px;
  white-space: nowrap;
  user-select: none;
}
.blk.motion { background: var(--accent); box-shadow: inset 0 -3px 0 var(--accent-dark); }
.blk.repeat { background: var(--repeat); box-shadow: inset 0 -3px 0 var(--repeat-dark); flex-direction: column; align-items: flex-start; padding: 8px 10px 10px; gap: 6px; }
.blk.repeat .rep-label { font-size: 15px; }
.blk.inner { margin-left: 12px; padding: 7px 12px; font-size: 15px; }
.blk.small { font-size: 13px; padding: 5px 8px; border-radius: 7px; }
.blk.repeat.small { padding: 4px 6px 6px; }
.blk.repeat.small .rep-label { font-size: 12px; }
.blk.inner.small { margin-left: 8px; padding: 3px 7px; font-size: 12px; }
.blk.active { outline: 4px solid #ffd84d; outline-offset: 1px; }
.blk.bad { outline: 4px solid var(--bad); outline-offset: 1px; }

/* ---------- общие кнопки */
.btn { border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 18px; }
.btn.go { background: var(--go); color: #fff; box-shadow: inset 0 -4px 0 var(--go-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: inset 0 -4px 0 var(--accent-dark); }
.btn:disabled { opacity: .45; }
